import itertools

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

NOW=[0]*(K+1)
NOW[0]=1#そこまでi個使ったときの場合の数


for a in A:
    NEXT=[0]*(K+1)
    NOWSUM=list(itertools.accumulate(NOW))
    NEXT=[NOWSUM[i]  if i<=a else 0 for i in range(K+1)]
    #print(NEXT)

    for j in range(a+1,K+1):
        NEXT[j]=(NOWSUM[j]-NOWSUM[j-a-1])%mod


    NOW=NEXT
    #print(NOWSUM,NOW)

print(NOW[K]%mod)