from itertools import accumulate

N,K = map(int,input().split())
A = list(map(int,input().split()))

dp = [[0]*(K+1) for _ in range(N+1)]
dp[0][0] = 1
MOD = 10**9+7

for i,a in enumerate(A):
    ac = [0] + list(accumulate(dp[i]))
    for j in range(K+1):
        dp[i+1][j] = (ac[j+1] - ac[max(0,j-a)]) % MOD
print(dp[-1][-1])