import sys
input = sys.stdin.readline

n, k = map(int,input().split())
A = list(map(int,input().split()))
mod = 10**9 + 7

D = [[0] * (k+2) for i in range(n+1)]
D[0][k] = 1
for i in range(1, n+1):
    for j in range(k+1):
        D[i][max(0, j-A[i-1])] = (D[i][max(0, j-A[i-1])] + D[i-1][j]) % mod
        D[i][j+1] = (D[i][j+1] - D[i-1][j]) % mod
    for j in range(1, k+2):
        D[i][j] = (D[i][j] + D[i][j-1]) % mod
print(D[-1][0])