from itertools import accumulate

def f(k, A):
    n = len(A)

    mod = int(1e9 + 7)
    dp = [0] * (k + 1)

    # init for last column
    for j in range(min(A[n - 1], k) + 1):
        dp[j] = 1

    for i in range(n - 2, -1, -1):
        dp = list(accumulate(dp))
        a = A[i]
        dp[a+1:] = [x - y for x, y in zip(dp[a + 1:], dp)]

    return dp[-1]

assert f(4, [2, 3]) == 2
assert f(4, [1, 2, 3]) == 5
assert f(10, [9]) == 0
assert f(0, [0, 0]) == 1
#assert f(100000, [100000, 100000, 100000, 100000]) == 665683269

n, k = map(int, input().split())
A = list(map(int, input().split()))
ans = f(k, A)
print(ans)
