N,K = map(int, input().split())
A = [int(a) for a in input().split()]

mod = 10**9+7

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