100 atcoder#AGC058B. [AGC058B] Adjacent Chmax
[AGC058B] Adjacent Chmax
Score : points
Problem Statement
You are given a permutation of .
You may perform the following operation zero or more times.
- Choose an integer (). Let and replace the values of and with .
How many sequences are there that can be after your operations? Find the count modulo .
Constraints
- is a permutation of .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3
1 3 2
4
The four sequences that can become are , , , and .
4
2 1 3 4
11
10
4 9 6 3 8 10 1 2 7 5
855