#P3970. [TJOI2014] 上升子序列

    ID: 2904 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2014线段树各省省选树状数组排序概率论,统计天津

[TJOI2014] 上升子序列

Description

Given a sequence containing only integers (the absolute value of each element does not exceed 10910^9), you need to count the number of increasing subsequences, where an increasing subsequence satisfies the following conditions:

  1. It is a subsequence of the original sequence.
  2. Its length is at least 22.
  3. All elements are strictly increasing.

If two increasing subsequences are identical, count them only once. For example, the sequence {1,2,3,3}\{1,2,3,3\} has 44 increasing subsequences: {1,2}\{1,2\}, {1,3}\{1,3\}, {1,2,3}\{1,2,3\}, {2,3}\{2,3\}.

Input Format

The first line contains an integer nn, the length of the sequence. The next line contains nn integers, the sequence elements.

Output Format

Output a single line: the number of increasing subsequences of the original sequence. Since the answer can be very large, output the remainder modulo 109+710^9 + 7.

4
1 2 3 3
4

Hint

Constraints

For 30%30\% of the testdata, n5000n \le 5000.

For 100%100\% of the testdata, n105n \le 10^5.

Translated by ChatGPT 5