from random import randint 
mod=10**9+7
def ways(n,k,arr):
	dp=[[0]*(k+1) for _ in range(n)]
	for i in range(arr[0]+1):
		dp[0][i]=1
	for i in range(1,n):
		s=0
		start=0
		for j in range(k+1):
			s+=dp[i-1][j]
			if s>mod:
				s-=mod
			dp[i][j]=s
			if j-start==arr[i]:
				s-=dp[i-1][start]
				if s<0:
					s+=mod
				start+=1

	return dp[n-1][k]
			

# with open ('input.txt') as f :
n,k=map(int,input().split())
arr=list(map(int,input().split()))
res=ways(n,k,arr)
# res=ways(100,10**5,[randint(0,10**5) for _ in range(100)])
print(res)





