#M

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)]
for i in range(N+1):
    dp[i][0]=1


for i in range(N):
    S=1
    for j in range(K):
        S+=dp[i][j+1]
        if j+1>a[i]:
            S-=dp[i][j-a[i]]
        dp[i+1][j+1]=S%mod
        
print(dp[-1][-1])



