LogiQuest

233. Coin Change — Number of Ways

MediumDynamic ProgrammingCounting

Count the ways to make the amount using unlimited coins of the given denominations (order does not matter). Print the count modulo 10⁹ + 7.

Input format

Line 1: k amount Line 2: k coin values

Output format

The number of ways mod 10⁹ + 7.

Example 1

Input

3 5
1 2 5

Output

4

Example 2

Input

1 3
2

Output

0

Constraints

1 ≤ k ≤ 100 0 ≤ amount ≤ 10⁵

Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.

Loading the MyLoginn IDE…