#P10592. BZOJ4361 isn
BZOJ4361 isn
Background
This problem comes from the original BZOJ. We acknowledge that the copyright of the statement and the original testdata belongs to the original BZOJ or the problem setter who authorized BZOJ to use it. If you are the copyright holder and believe that we have infringed your rights, please contact us.
Problem Description
You are given a sequence of length . If the sequence is not non-decreasing, you must delete one number from it.
This operation will be performed repeatedly until becomes non-decreasing. Find how many different operation plans there are. Two operation plans are considered different if and only if the deletion order or the number of deletions is different. Output the answer modulo .
Input Format
The first line contains a positive integer , representing the length of the sequence.
The second line contains non-negative integers , representing the sequence.
Output Format
Output one integer per line, representing the value of the answer modulo .
4
1 7 5 3
18
Hint
For of the testdata, , and .
Translated by ChatGPT 5