import numpy as np
from numba import njit

@njit( cache=True)
def main():
    N,K=map(int,input().split())
    a=np.array([int(i) for i in input().split()],dtype=np.int64)
    MOD=10**9+7

    dp=np.full((N+1,K+1),0,dtype=np.int64)
    c=np.full(K+2,0,dtype=np.int64)

    dp[0][0]=1


    for i in range(1,N+1):
        c[0]=0
        for j in range(1,K+2):
            c[j]=(c[j-1]+dp[i-1][j-1])%MOD
        for j in range(K+1):
            dp[i][j]=(c[j+1]-c[max(0,j-a[i-1])])%MOD

    print(dp[N][K])

def main()
