CntSeq

Time limit: 1s
Memory limit: 256MB
Input:
Output:

RMN wasted all his money on sports betting... again. However, he still feels the need of betting just one more time in order to at least recover his losses.

The only issue is that he needs a big sum to get a good return on his last "safe" bet. Because he doesn't have a lot of skills, he can't get this money too easily. Luckily, a man in the parking spot of a gas station offered him 100 RON if he can count how many substrings of an integer sequence have their maximum value between two given values.

More formally, RMN receives an integer sequence AA of NN numbers, and two integers LL and UU. He is asked to count how many substrings S=A[i,i+1j]S = A[i,i+1\cdots j] have Lmax(S)UL \leq max(S) \leq U.

Help RMN retire in glory by winning the 100 RON needed for his first win!

P.S. He will probably lose anyway :(

Input data

The first line will contain 3 integers NN (1N105 1 \leq N \leq 10^5), LL (1018L1018-10^{18} \leq L \leq 10^{18}), UU (1018U1018-10^{18} \leq U \leq 10^{18}) - the length of the array AA, the lower and the upper bounds for the maximum of the substrings that need to be counted.
The following line will contain NN integers between 1018-10^{18} and 101810^{18} - the values of the sequence AA.

Output data

The only line will contain a single integer - the number of substrings of AA with their maximum value between LL and UU.

Constraints and clarifications

  • For 2525 points, it is guaranteed that N500N \leq 500;
  • For another 2525 points, it is guaranteed that N5 000N \leq 5 \ 000;
  • For the last 5050 points, we have N105N \leq 10^5.

Example

stdin

5 3 4
1 5 2 4 3

stdout

5

Explanation

The substrings with their maximum value between 3 and 4 are: [4],[2,4],[4,3],[4,3,2],[3][4], [2,4], [4,3], [4,3,2], [3]

Log in or sign up to be able to send submissions!