def solve():
  N, K = map(int, input().split())
  A = list(map(int, input().split()))
  mod = 10**9+7
  dp = [[0]*(K+2) for _ in range(N+1)]
  dp[0] = [0]+[1]*(K+1)
  for n in range(1,N+1):
    for k in range(1,K+2):
      dp[n][k] = (dp[n-1][k]-dp[n-1][max(0,k-A[n-1]-1)]+dp[n][k-1])%mod
  ans = (dp[-1][-1]-dp[-1][-2])%mod
  return ans
print(solve())