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