#P9710. [KMOI R1] 五五五五(Easy)
[KMOI R1] 五五五五(Easy)
Background
“Numbers in slow order are not born from the supernatural. They have a form that can be checked, and a quantity that can be inferred.” — Zu Chongzhi.
Problem Description
Xiao Song has a sequence . For , it satisfies .
For , he defines as the number of consecutive trailing ’s at the end of .
For example, for the sequence , we have and .
Now please compute:
$$\Big(\sum\limits_{l=1}^ {n}\sum\limits_{r=l}^{n} f(l,r)\Big) \bmod 10^9+7$$Input Format
The first line contains a positive integer , representing the length of the sequence.
The second line contains integers , representing the sequence .
Output Format
One positive integer , representing the answer.
2
5 5
4
4
1 1 4 5
4
Hint
Explanation for Sample :
.
.
.
So the answer is , therefore output .
Constraints
This problem uses bundled subtask testdata.
Let .
| Subtask ID | Test Point ID | Special Property | Score | ||
|---|---|---|---|---|---|
| None | |||||
| None | |||||
| None | |||||
Special property The average of the sequence is .
Special property The sequence is monotone non-increasing.
For of the data: , .
For , it holds that .
Translated by ChatGPT 5