n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

mod = 10 ** 9 + 7
dp = [0] * (k + 1)

dp[0] = 1

for i in a:
    neg = [0] * (k + 1)
    s = 0
    dp2 = [0] * (k + 1)
    
    for j in range(k + 1):
        s += dp[j]
        s %= mod
        dp2[j] = s
        neg[min(k, j + i)] += dp[j]
        s -= neg[j]
    
    dp = dp2

print(dp[-1])