#P11079. 「FSLOI Round I」山峦
「FSLOI Round I」山峦
Description
An integer sequence of length is called a peak if and only if it satisfies the following condition:
- There exists an integer where . We call as the height of the peak.
An integer sequence is called a mountain if and only if it satisfies one of the following conditions:
-
is a peak.
-
can be split into at least two continuous subsequences, where each subsequence is a peak and the heights of the peaks are strictly increasing from left to right.
For example, the sequence is a mountain, because it can be split into two peaks: and , and the heights of the peaks are strictly increasing. is not a peak because it itself isn't a peak and it cannot be split into multiple peaks.
You are given a sequence of length . You need to find out the number of mountains among all the subsequences of .
The answer may be very large, so please print the answer modulo .
Note that, for two subsequences and , they are different if and only if . In other words, even if two subsequences have the same elements, they are distinguished as long as the positions of the elements are different.
Input Format
The first line of the input contains a single integer representing the length of the given sequence.
The second line contains integers , representing the sequence .
Output Format
Output a single integer, representing the answer modulo .
4
1 2 2 1
2
7
2 4 3 1 5 2 1
35
20
2 3 5 6 8 7 6 5 6 7 8 8 8 8 4 3 5 6 7 4
15085
Hint
Example Explanation
In the first example, and are mountains.
Constraints
Subtasks are used in this problem.
For all tests, it is guaranteed that:
| Subtask Id | Score | Special Property |
|---|---|---|
| - |
Special Property : is a peak.
Special Property : are pairwise distinct.
京公网安备 11011102002149号