from itertools import accumulate
n,k = map(int,input().split())
a = list(map(int,input().split()))
mod = 10**9+7
dp = [[0 for i in range(k+1)] for j in range(n+1)]
dp[0][0] = 1
asum = 0
for i in range(1,n+1):
  acc = list(accumulate(dp[i-1]))
  ai = a[i-1]
  asum += ai
  for j in range(min(k,asum)+1):
    dp[i][j] = acc[j]
    if j > ai:
      dp[i][j] -= acc[j-ai-1]
    dp[i][j] %= mod
print(dp[n][k])