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個の飴を分ける組み合わせ
dp[0][0] = 1
	
for k in range(1, K + 1):
	sum = 0
	for n in range(N):
		sum += dp[n][k - 1]
		dp[n][k] = max(0, sum + min(a[n] - k, 0))
		dp[n][k] %= mod
		
ans = 0

for n in range(N):
	ans += dp[n][K]
	ans %= mod
	
print(ans)
