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

ans = 0
MOD = 10**9 + 7
dp = [[0] * (k+1) for _ in range(n+1)]
dp[0][0] = 1

for i in range(n):
    sums = [0] * (k+2)
    for j in range(k+1): #|累積和
        sums[j+1] = sums[j] + dp[i][j]
        sums[j+1] %= MOD
    for j in range(k+1):
        dp[i+1][j] = sums[j+1] - sums[max(0, j-lst[i])]
        dp[i+1][j] %= MOD #累積和を利用した区間和
print(dp[n][k])