N,K=map(int,input().split())
a=list(map(int,input().split()))

mod=10**9+7
dp=[[0]*(K+1) for i in range(N+1)]
dp[0][0]=1

for i in range(N):
  acc=[0]*(K+2)
  for j in range(K+1):
    acc[j+1]=acc[j]+dp[i][j]
    acc[j+1]%=mod
  for j in range(K+1):
    dp[i+1][j]=acc[j+1]-acc[max(0,j-a[i])]
    dp[i+1][j]%=mod
print(dp[N][K])
