N,K=map(int,input().split())
a=[int(i) for i in input().split()]
mod=10**9+7
dp=[[0]*(K+1) for i in range(N+1)]
dp[0][0]=1
dp_sum=[[0]*(K+2) for i in range(N+1)]
dp_sum[0]=[0]+[1]*(K+1)
for i in range(N):
  for k in range(K+1):
    dp[i+1][k]=(dp_sum[i][k+1]-dp_sum[i][max(k-a[i],0)])%mod
    dp_sum[i+1][k+1]=(dp_sum[i+1][k]+dp[i+1][k])%mod
print(dp[N][K])
