N,K=map(int,input().split())
A=list(map(int,input().split()))
mod=10**9+7

dp=[[0 for i in range(0,K+1)] for i in range(0,N)]
for i in range(0,K+1):
    if A[0]>=i:
        dp[0][i]=1

for i in range(1,N):
    for j in range(0,K+1):
        if j==0:
            dp[i][j]=dp[i-1][j]
        elif A[i]>=j:
            dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod
        else:
            dp[i][j]=(dp[i][j-1]+dp[i-1][j]-dp[i-1][j-1-A[i]])%mod

print(dp[N-1][K])