N,K = map(int,input().split())
A = map(int,input().split())
MOD = 10**9 + 7

dp = [0]*(1+K)
dp[0] = 1

for a in A:
  t,dp[K] = dp[K], sum(dp[j] for j in range(K-a,K+1)) % MOD

  for i in reversed(range(K)):
    t,dp[i] = dp[i], (dp[i+1]-t+(dp[i-a] if i >= a else 0)) % MOD

print(dp[K])