# -*- coding: utf-8 -*-
import sys

N,K=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())


dp=[ [] for i in range(N+1) ]
dp[0]=[1]


for i in range(1,N+1):
	W=[]		#WA:累積和
	U=dp[i-1]	#Unit：累積和を計算する前の単位配列
	l=len(U)+A[i-1]	#i行目の配列の長さ

	for j,x in enumerate(U):
		if j==0:	W.append(x)
		else:	W.append(W[-1]+x)

	len_w=len(W)

	L=[]		#dp[i]の配列
	for k in range(l):
		L.append( W[min(k, len_w-1)] )

	for k in range(l-1,-1,-1):
		L[k]=min( L[k] , W[min(l-k-1, len_w-1)] )

	dp[i]=L


try:
	print dp[N][K]%(10**9+7)
except:
	print 0
