N, K = map(int, input().split())
a = list(map(int, input().split()))
dp = [[0 for i in range(K+10)] for j in range(N+10)]
mod = int(1e9) + 7
dp[0][0] = 1
for i in range(N):
    pSum = [0 for _ in range(K+10)]
    for j in range(K+1):
        pSum[j + 1] = (pSum[j] + dp[i][j]) % mod
    for j in range(K+1):
        if i >= len(a):
            continue
        dp[i+1][j] = (pSum[j+1] - pSum[max(0, j - a[i])]) % mod
print(dp[N][K])