import sys
input = sys.stdin.readline

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

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

dp[0][0] = 1

cum = [0]*(K+2)

for i in range(1,N+1) :
    cum[0] = 1
    for j in range(1,K+2) :
        cum[j] = (cum[j-1] + dp[i-1][j-1]) % (10**9+7)
    for j in range(K+1) :
        dp[i][j] = (cum[j+1] - cum[max(0, j-A[i-1])] + (10**9+7)) % (10**9+7)

ans = dp[N][K]

print(ans)
#print(dp)
