atcoder#ABC221E. [ABC221E] LEQ
[ABC221E] LEQ
Score : points
Problem Statement
Given is a sequence of integers: .
Find the number of (not necessarily contiguous) subsequences of length at least that satisfy the following condition:
- .
Since the count can be enormous, print it modulo .
Here, two subsequences are distinguished when they originate from different sets of indices, even if they are the same as sequences.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the number of (not necessarily contiguous) subsequences of length at least that satisfy the condition in Problem Statement.
3
1 2 1
3
has four (not necessarily contiguous) subsequences of length at least : , , , .
Three of them, , , , satisfy the condition in Problem Statement.
3
1 2 2
4
Note that two subsequences are distinguished when they originate from different sets of indices, even if they are the same as sequences.
In this Sample, there are four subsequences, , , , , that satisfy the condition.
3
3 2 1
0
There may be no subsequence that satisfies the condition.
10
198495780 28463047 859606611 212983738 946249513 789612890 782044670 700201033 367981604 302538501
830