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