N, K = map(int, input().split())
A = list(map(int, input().split()))
MOD = 10**9+7
dp = [[0 for j in range(K+10)] for i in range(N+10)]
#初期化
for l in range(A[0]+1):
    dp[0][l] = 1

for i in range(1,N):
    for k in range(K+1):
        dp[i][k] = dp[i-1][k] + dp[i][k-1] - dp[i-1][max(-1, k-A[i]-1)]
        dp[i][k] %= MOD
print(dp[N-1][K])