eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

A Huge Tower

A Huge Tower

Ліміт часу 1 секунда
Ліміт використання пам'яті 256 MiB

The ancient Babylonians decided to build a huge tower. The tower consists of N cubic building blocks that are stacked one onto another. The Babylonians gathered many building blocks of various sizes from all over the country. From their last unsuccessful attempt they have learned that if they put a large block directly onto a much smaller block, the tower will fall.

Each two building blocks are different, even if they have the same size. For each building block you are given its side length. You are also given an integer D with the following meaning: you are not allowed to put block A directly onto block B if the side length of A is strictly larger than D plus the side length of B.

Compute the number of different ways in which it is possible to build the tower using all the building blocks. Since this number can be very large, output the result modulo 10^9+9.

Вхідні дані

The first line of the input contains two positive integers N and D: the number of building blocks and the tolerance respectively.

The second line contains N space-separated integers; each represents the size of one building block.

Constraints

All numbers in the input files are positive integers not exceeding 10^9.

N is always at least 2.

In test cases worth 70 points N will be at most 70.

Out of those, in test cases worth 45 points, N will be at most 20.

Out of those, in test cases worth 10 points, N will be at most 10.

For some of the test cases the total number of valid towers will not exceed 1000000. These test cases are worth 30 points in total.

For the last six test cases (worth 30 points) the value of N is larger than 70. No upper bound on N is given for these test cases.

Вихідні дані

Output a single line containing a single integer: the number of towers that can be built, modulo 1000000009.

Приклад

Вхідні дані #1
4 1
1 2 3 100
Вихідні дані #1
4
Автор Michal Forišek