mod = 10**9+7
N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0]*(K+1) for i in range(N+1)]
S = [0] * (K+2)
dp[0][0] = 1
for i in range(1,N+1):
    for j in range(1,K+2):
        S[j] = (S[j-1] + dp[i-1][j-1])%mod
    for j in range(K+1):
        dp[i][j] = (S[j+1] - S[max(0, j-a[i-1])])%mod
print(dp[N][K])