import numpy as np

mod = 10**9 + 7

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

dp = np.zeros(k+1, dtype=np.int64)
dp[0] = 1

for i in range(n):
    dp = dp.cumsum()
    r = a[i]+1
    dp[r:] -= dp[:-r]
    dp %= mod
print(dp[-1])
