from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
import math

rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')

def pprint(M):
	for row in M:
		print(row)
	print("~~~")

def main():
	MOD = 10**9 + 7
	n, k = rli()
	A = list(rli())
	P = [A[0]]
	for i in range(1, len(A)):
		P.append(P[-1] + A[i])
	dp = [[0 for __ in range(k+1)] for _ in range(n)]
	psums = [[0 for __ in range(k+1)] for _ in range(n)]
	for c in range(min(k+1, A[0] + 1)):
		dp[0][c] = 1
	psums[0][0] = dp[0][0]
	for c in range(1, k+1):
		psums[0][c] = dp[0][c] + psums[0][c-1]
	for r in range(1, n):
		for c in range(min(k + 1, P[r] + 1)):
			cutoff = c - A[r] - 1
			dp[r][c] = psums[r-1][c] - (psums[r-1][cutoff] if cutoff >= 0 else 0)
		psums[r][0] = dp[r][0]
		for c in range(1, k + 1):
			psums[r][c] = dp[r][c] + psums[r][c-1]
	print(dp[n-1][k] % MOD)
	stdout.close()

if __name__ == "__main__":
	main()