# coding: utf-8
# Your code here!
MOD=10**9+7

n,k = [int(i) for i in input().split()]
aa = [int(i) for i in input().split()]

dp=[0]*(2*k+1)
dp[0]=1
for a in aa:
    l=k-a
    s=sum(dp[l:k+1])%MOD
    for i in range(k,-1,-1):
#        print(s,i,l)
        s-=dp[i]
        s%=MOD
        dp[i] += s
        l-=1
        s+=dp[l]
#    print(dp)
        
    
print(dp[k]%MOD)
