n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
dp = [[0]*(k+1) for i in range(n+1)]
dp[0][0] = 1
dp_sum = [[0]*(k+1) for i in range(n+1)]
for i in range(k+1):
    dp_sum[0][i] = 1
for i in range(n):
    for j in range(k+1):
        dp[i+1][j] += dp_sum[i][j]
        if j - a[i] > 0:
            dp[i+1][j] -= dp_sum[i][j-a[i]-1]
        if j -1 >= 0:
            dp_sum[i+1][j] = dp_sum[i+1][j-1]+dp[i+1][j]
        else:
            dp_sum[i+1][j] = dp[i+1][j]
        dp[i+1][j] %= mod
        dp_sum[i+1][j] %= mod
print(dp[-1][-1]%mod)