mod=10**9+7
n,k=map(int,input().split())
arr=list(map(int,input().split()))
dp=[[0]*(k+1) for _ in range(n+1)]
dp[0][0]=1
acum=[1]*(k+2)
acum[0]=0
for i in range(n):
  tmp=[0]
  for j in range(k+1):
    dp[i+1][j]=acum[j+1]-acum[max(0,j-arr[i])]
    dp[i+1][j]%=mod
    tmp.append((tmp[-1]+dp[i+1][j])%mod)
  acum=tmp
print(dp[-1][k]%mod)