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)
dp[0] = 1

for ai in a:
    dp = dp.cumsum()
    dp[ai+1:] -= dp[:-(ai+1)]
    dp %= mod
print(int(dp[-1]))
