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

candies = list(map(int,input().split()))

dp = [0] * (k+1)
minimo = [1] * (k+2)

mod = 1e9 + 7

dp[0] = 1
minimo[0] = 0

for i in range(1, n + 1):
    soma = [0] * (k+2)

    for j in range(k+1):
        dp[j] = (minimo[j+1] - minimo[max(0, j - min(k,candies[i-1]))]) % mod
        soma[j+1] = (soma[j] + dp[j]) % mod

    minimo = soma

print(int(dp[k]))
