Replica Spread
A storage cluster keeps k identical replicas of a hot object. Before choosing where to put them,
the placement service wants to know how many options it actually has.
There are n servers, numbered from 1 to n. Server i has room for at most c_i replicas of the
object (it may also hold none). A placement assigns a whole number of replicas x_i to each
server so that 0 ≤ x_i ≤ c_i for every i and x_1 + x_2 + … + x_n = k. Replicas are
indistinguishable, so two placements differ exactly when some server holds a different number of
replicas in them.
Count the distinct placements. Since the number can be huge, print it modulo 1 000 000 007.
Input
The first line contains two integers n and k (1 ≤ n ≤ 100, 0 ≤ k ≤ 10^5): the number of servers
and the number of replicas.
The second line contains n integers c_1, c_2, …, c_n (0 ≤ c_i ≤ 10^5): the capacity of each
server.
Output
Print one integer: the number of placements modulo 1 000 000 007. If the replicas cannot be placed
at all, print 0.
Notes
In the first example the valid placements (x_1, x_2, x_3) are (0, 1, 3), (1, 0, 3),
(1, 1, 2), (2, 0, 2) and (2, 1, 1).
In the second example the servers can hold only 6 replicas in total, so 7 replicas cannot be placed.
When k = 0 there is exactly one placement: every server holds nothing.