409219: GYM103462 K K-Clearing II
Description
You are given an array $$$a$$$ of $$$n$$$ integers.
While there is at least one element equal to $$$k$$$ in the array, then you should make all the positive elements in the array minus one. In other words, $$$a_i=a_i-1(1\leq i\leq n;a_i > 0)$$$.
Please calculate the sum of the number of elements equal to $$$0$$$ after clear all elements equal to $$$k$$$ in all subarray containing $$$m$$$ consecutive elements in the array $$$a$$$.
InputThe first line contains three integers $$$n,m(1\leq m\leq n\leq 10^6)$$$, $$$k(1\leq k\leq 10^9)$$$ — the length of $$$a$$$, the length of the subarray and the number we need to clear.
The second line contains $$$n$$$ integers $$$ a_1,a_2,...,a_n(1\leq a_i\leq 10^9)$$$.
OutputOutput an integer representing the answer.
ExamplesInput5 3 1 1 2 3 4 5Output
3Input
6 3 1 1 1 4 5 1 4Output
5Note
In the second sample, there are $$$4$$$ subarrays in $$$a$$$ with length $$$m$$$:
1.$$$[1,1,4]$$$, and $$$[0,0,3]$$$ after clear the $$$k$$$
2.$$$[1,4,5]$$$, and $$$[0,3,4]$$$ after clear the $$$k$$$
3.$$$[4,5,1]$$$, and $$$[3,4,0]$$$ after clear the $$$k$$$
3.$$$[5,1,4]$$$, and $$$[4,0,3]$$$ after clear the $$$k$$$
So the sum of the number of elements equal to $$$0$$$ is $$$5$$$.