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 + 1)]
#dp[n][k]...n人目まででk個の飴を分ける組み合わせ
dp[0][0] = 1
	
for n in range(1, N + 1):
	#cum...累積和
	cum = [0] * (K + 2)
	for k in range(K + 1):
		cum[k + 1] = cum[k] + dp[n - 1][k]
		dp[n][k] = cum[k + 1] - cum[max(0, k - a[n - 1])]
		dp[n][k] %= mod

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