import itertools



N, K = list(map(int, input().split()))

A = tuple(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(1, N + 1):

    S = [0] + list(itertools.accumulate(dp[i - 1]))

    for j in range(K + 1):

        dp[i][j] = (S[j + 1] - S[max(0, j - A[i - 1])]) % MOD

print((dp[N][K]))

import numpy as np



N, K = list(map(int, input().split()))

A = tuple(map(int, input().split()))



MOD = 10 ** 9 + 7



dp = np.zeros((N + 1, K + 1), dtype=np.int64)

dp[0][0] = 1

for i in range(1, N + 1):

    S = np.cumsum(dp[i - 1]) % MOD

    dp[i][:A[i - 1] + 1] = S[:A[i - 1] + 1] % MOD

    dp[i][A[i - 1] + 1:K + 1] = (S[A[i - 1] + 1:K + 1] - S[:K - A[i - 1]]) % MOD

print((dp[N][K]))

import itertools

N, K = list(map(int, input().split()))
A = tuple(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(1, N + 1):
    S = [0] + list(itertools.accumulate(dp[i - 1]))
    for j in range(K + 1):
        dp[i][j] = (S[j + 1] - S[max(0, j - A[i - 1])]) % MOD
print((dp[N][K]))

import numpy as np

N, K = list(map(int, input().split()))
A = tuple(map(int, input().split()))
MOD = 10**9 + 7
dp = np.zeros((N + 1, K + 1), dtype=np.int64)
dp[0][0] = 1
for i in range(1, N + 1):
    S = np.cumsum(dp[i - 1]) % MOD
    dp[i][: A[i - 1] + 1] = S[: A[i - 1] + 1] % MOD
    dp[i][A[i - 1] + 1 : K + 1] = (S[A[i - 1] + 1 : K + 1] - S[: K - A[i - 1]]) % MOD
print((dp[N][K]))

-import itertools +import numpy as np -dp = [[0] * (K + 1) for _ in range(N + 1)] +dp = np.zeros((N + 1, K + 1), dtype=np.int64) -    S = [0] + list(itertools.accumulate(dp[i - 1])) -    for j in range(K + 1): -        dp[i][j] = (S[j + 1] - S[max(0, j - A[i - 1])]) % MOD +    S = np.cumsum(dp[i - 1]) % MOD +    dp[i][: A[i - 1] + 1] = S[: A[i - 1] + 1] % MOD +    dp[i][A[i - 1] + 1 : K + 1] = (S[A[i - 1] + 1 : K + 1] - S[: K - A[i - 1]]) % MOD