##x_1+x_2+...+x_N=K, 0<=x_i<=a_i
N,K=list(map(int,input().strip().split(' ')))
A=list(map(int,input().strip().split(' ')))
dp=[[0] * (K+1)  for i in range(N)]
for i in range(min(A[0]+1,K+1)):
    dp[0][i]=1
for i in range(N):
    dp[i][0]=1
MOD=10**9+7
for i in range(1,N):
    pre=[]
    temp=0
    for j in range(K+1):
        temp+=dp[i-1][j]
        temp%=MOD
        pre+=[temp]
        
    for j in range(1,K+1):
        ## j-A[i],j-(A[i]-1),...,j
        ## pre[j]-pre[j-A[i]-1]
        temp=0
        if j-A[i]>0:
            temp=pre[j-A[i]-1]
        dp[i][j]=pre[j]-temp
        dp[i][j]%=MOD

print(dp[-1][K])
        
        


