N, K = map(int, input().split())

max_candies = list(map(int, input().split()))

dpt = [[0] * (K+1) for i in range(N+1)]
for i in range(K+1):
    dpt[0][i] = 1

for i in range(1, N+1):
    for j in range(0, K+1):
        dpt[i][j] += dpt[i-1][j]
        t = j - max_candies[i-1] - 1
        if t >= 0:
            dpt[i][j] -= dpt[i-1][t]
        if j > 0:
            dpt[i][j] += dpt[i][j-1]
        dpt[i][j] = dpt[i][j] % (10**9+7)

print((dpt[N][K]-dpt[N][K-1]) % (10**9+7))
