mod = 10**9+7
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [0]*(K+1)

for i in range(a[0]+1):
    dp[i] = 1
for i in range(1, N):
    S = [0]*(K+2)
    for j in range(1, K+2):
        S[j] = S[j-1]+dp[j-1]
        S[j]%=mod
    for j in range(K+1):
        dp[j] = (S[j+1]-S[max(0, j-a[i])])%mod
print(dp[-1])




