def solve2(ls, k):
	dp = [0 for i in range(k + 1)]
	dp[0] = 1
	for child in ls:
		fake = [0 for i in range(k + 2)]
		for used in range(k, -1, -1):
			left = 1 + used
			left_till = min(k - used, child) + used
			if left <= left_till:
				fake[left] += dp[used]
				fake[left_till + 1] -= dp[used]
		sm = 0
		for i in range(k + 1):
			sm += fake[i]
			dp[i] += sm

	return dp[k] % 1000000007


n, k = map(int, input().split())
ls = list(map(int, input().split()))
print(solve2(ls, k))
