After setting all his ideas for bugaboos, Max has decided to blindly steal from others he saw online.
Recently, he read an interesting bugaboo on a new online judge called JOMD:
Given an array of length
, , find the number of subarrays such that .
Note:
This bugaboo stumped Max, so he asked you for help.
Can you help him?
Constraints
Subtask 1 [20%]
Subtask 2 [80%]
Note: Fast I/O might be required to fully solve this problem (e.g., BufferedReader for Java).
Input Specification
The first line will contain
The next line will contain
Output Specification
Output the number of distinct subarrays that have a difference between the maximum and minimum in
Sample Input
8 3 3
1 4 5 2 2 -3 -5 -6
Sample Output
6
Explanation for Sample Output
There are
Comments