import itertools
import copy

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

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

def funct(a,b):
    return (a+b)%mod

for a in A:
    NEXT=[0]*(K+1)
    NOWSUM=list(itertools.accumulate(NOW,funct))
    NEXT=copy.copy(NOWSUM)
    #print(NEXT)

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


    NOW=NEXT
    #print(NOWSUM,NOW)

print(NOW[K]%mod)