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):
    ni = i + 1
    ruiseki = [0] * (k + 1)
    pre = 0
    for j in range(k + 1):
        ruiseki[j] += pre
        ruiseki[j] += dp[i][j]
        pre = ruiseki[j]
        dp[ni][j] += ruiseki[j]
        if j - A[i] > 0:
            dp[ni][j] -= ruiseki[j - A[i] - 1]
        dp[ni][j] %= mod
print(dp[n][k])
