#arc110d. [arc110_d]Binomial Coefficient is Fun

[arc110_d]Binomial Coefficient is Fun

Problem Statement

We have a sequence AA of NN non-negative integers.

Compute the sum of prodi=1NdbinomBiAi\\prod _{i = 1} ^N \\dbinom{B_i}{A_i} over all sequences BB of NN non-negative integers whose sum is at most MM, and print it modulo (109+710^9 + 7).

Here, dbinomBiAi\\dbinom{B_i}{A_i}, the binomial coefficient, denotes the number of ways to choose AiA_i objects from BiB_i objects, and is 00 when Bi<AiB_i < A_i.

Constraints

  • All values in input are integers.
  • 1leqNleq20001 \\leq N \\leq 2000
  • 1leqMleq1091 \\leq M \\leq 10^9
  • 0leqAileq20000 \\leq A_i \\leq 2000

Input

Input is given from Standard Input in the following format:

NN MM A1A_1 A2A_2 ldots\\ldots ANA_N

Output

Print the sum of prodi=1NdbinomBiAi\\prod _{i = 1} ^N \\dbinom{B_i}{A_i}, modulo (109+7)(10^9 + 7).


Sample Input 1

3 5
1 2 1

Sample Output 1

8

There are four sequences BB such that prodi=1NdbinomBiAi\\prod _{i = 1} ^N \\dbinom{B_i}{A_i} is at least 11:

  • B=1,2,1B = \\{1, 2, 1\\}, where $\\prod _{i = 1} ^N \\dbinom{B_i}{A_i} = \\dbinom{1}{1} \\times \\dbinom{2}{2} \\times \\dbinom{1}{1} = 1$;

  • B=2,2,1B = \\{2, 2, 1\\}, where $\\prod _{i = 1} ^N \\dbinom{B_i}{A_i} = \\dbinom{2}{1} \\times \\dbinom{2}{2} \\times \\dbinom{1}{1} = 2$;

  • B=1,3,1B = \\{1, 3, 1\\}, where $\\prod _{i = 1} ^N \\dbinom{B_i}{A_i} = \\dbinom{1}{1} \\times \\dbinom{3}{2} \\times \\dbinom{1}{1} = 3$;

  • B=1,2,2B = \\{1, 2, 2\\}, where $\\prod _{i = 1} ^N \\dbinom{B_i}{A_i} = \\dbinom{1}{1} \\times \\dbinom{2}{2} \\times \\dbinom{2}{1} = 2$.

The sum of these is 1+2+3+2=81 + 2 + 3 + 2 = 8.


Sample Input 2

10 998244353
31 41 59 26 53 58 97 93 23 84

Sample Output 2

642612171