import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, K = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
dp = [[0] * (K + 1) for _ in range(N)]
#dp[n][k]...n+1人目まででk個の飴を分ける組み合わせ

for i in range(1, N):
	a[i] = a[i - 1] + a[i]
	
for n in range(N):
	for k in range(K + 1):
		if k == 0:
			dp[n][k] = 1
		elif a[n] < k:
			dp[n][k] = 0
		else:
			dp[n][k] = (dp[n - 1][k] + dp[n][k - 1]) % mod
			

print(dp[-1][-1])