n,k=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7
dp=[[0]*(k+2) for i in range(n+1)]
dp[0][0]=1
B=[0]*(2*k+3) #累積和list
for i in range(1,n+1):
  for j in range(k+1):
    B[j]=B[j-1]+dp[i-1][j]
  for j in range(k+1):
    dp[i][j]=(B[j]-B[j-A[i-1]-1])%mod
print(dp[n][k])