N, K = map(int, input().split())
a = list(map(int, input().split()))
mod = 10**9+7

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