mod=10**9+7
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
DP=[[0]*(k+1) for _ in range(n)]
acc=[0]*(k+2)
for i in range(k+1):
    if i<=A[0]:
        DP[0][i]=1
    acc[i+1]=acc[i]+DP[0][i]
for i in range(1,n):
    for j in range(k+1):
        DP[i][j]=(acc[j+1]-acc[max(0,j-A[i])])%mod
    acc[0]=0
    for j in range(k+1):
        acc[j+1]=(acc[j]+DP[i][j])%mod
print(DP[-1][-1])