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

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

for i in range(1, N+1):
    v = a[i-1]
    dp[i][0] += dp[i-1][0]
    dp[i][0] %= mod
    for j in range(1,K+1):
        if j-1-v >= 0:
            dp[i][j] += (dp[i][j-1] + dp[i-1][j] - dp[i-1][j-1-v]) % mod
        else:
            dp[i][j] += (dp[i][j-1] + dp[i-1][j]) % mod
if K>0:            
    ans = (dp[N][K] - dp[N][K-1]) % mod
else:
    ans = dp[N][K] % mod
print(ans)