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

dp = [[0]*(k+1) for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    dpsum = [0]*(k+2)
    for l in range(k+1):
        dpsum[l+1] = dpsum[l] + dp[i][l]
        dpsum[l+1] %= mod
    for j in range(k+1):
        dp[i+1][j] = (dpsum[j+1] - dpsum[max(0,j-a[i])])%mod
print(dp[n][k])
