Subșiruri importante

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

Gomory and Hu found an array of natural numbers in the basement of their house. While wondering what the meaning of this array might be, they started playing with several subsequences of it, eventually reaching contradictory opinions.

Gomory is firmly convinced that a subsequence which could reveal important information is one in which the absolute difference between the values of any two elements is less than or equal to a number KK. At the same time, Hu completely disagrees with this statement, considering that a subsequence would be important if the absolute difference between the positions of any two elements is less than or equal to a number DD.

After a long argument, they ask for your help in finding the number of subsequences that are important to both of them.

Task

Formally, you are given an array VV of natural numbers, of length NN. You must compute the number of subsequences of this array in which the absolute difference between the values of any two elements is less than or equal to KK and the absolute difference between the positions of any two elements is less than or equal to DD.

Input Data

On the first line, the natural numbers NN, KK and DD are read, with the meaning given in the statement.

On the second line, the NN natural numbers that form the array VV are read, separated by spaces.

Output Data

You must output a single natural number representing the number of subsequences of the array VV in which the absolute difference between any two values is less than or equal to KK and the absolute difference between the positions of any two elements is less than or equal to DD, modulo 109+710^9+7.

Constraints

  • 1DN2000001 \le D \le N \le 200\,000
  • 1K, Vi1091 \le K,\ V_i \le 10^9
  • A subsequence is obtained from the original array by removing elements at arbitrary positions.
# Points Restrictions
1 10 N20N \le 20
2 10 D=ND = N
3 20 D50D \le 50
4 20 N1000N \le 1\,000
5 40 No additional constraints

Example

stdin

5 10 3
20 10 30 40 10

stdout

9

Explanation

In the given example, the good subsequences are: (20)(20), (20,10)(20,10), (20,30)(20,30), (10)(10), (10,10)(10,10), (30)(30), (30,40)(30,40), (40)(40), (10)(10).

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