n,k = map(int,input().split())
al = list(map(int,input().split()))

# i番目までの子供でj個の飴を分け合う組み合わせ
dp = [[0 for j in range(k+1)] for i in range(n+1)]


for i in range(n+1):
    dp[i][0] = 1
MOD = 10**9 + 7

for i in range(1,n+1):
    for j in range(1,k+1):
        if j-al[i-1]-1 >= 0:
            dp[i][j] = dp[i][j-1] + dp[i-1][j] - dp[i-1][j-al[i-1]-1]
            dp[i][j] %= MOD
        else:
            dp[i][j] = dp[i][j - 1] + dp[i - 1][j]
            dp[i][j] %= MOD
print(dp[n][k])


