n, k = map(int, input().split())
ns = 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):
    b = 0
    cur = [0]
    for j in range(k+1):
        b += dp[i][j] % mod
        cur.append(b)
    for j in range(k+1):
        dp[i+1][j] = (cur[j+1] - cur[max(0, j-ns[i])]) % mod
print(dp[-1][-1]) 
    