#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
typedef long long int ld;
typedef unsigned long long int lu;
typedef vector< int > vi;
typedef vector < ld > vd;
typedef set <ld> sd;
typedef vector< vi > vvi;
typedef vector< vd > vvd;
typedef pair< int,int > ii;
typedef pair< ld,ld > id;
#define sz(a) ld((a).size())
#define test(t) ll t;cin>>t;while(t--)
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define Vi vector
#define pr pair
#define mpr make_pair
#define fi first
#define se second
#define isnum(a) (a>=48 && a<=57)
#define isS(a) (a>='a' && a<='z')
#define isU(a) (a>='A' && a<='Z')
#define toS(a) (isU(a)?a+32:a)
#define toU(a) (isS(a)?a-32:a)
#define toC(a) a&15

set <ld> s[100005];
ld d[100005];

vector<char> prime (100000+1, true);
void sieve(ld n)
{	
	//O(nloglogn) time
	prime[0] = prime[1] = false;
	for (ld i=2; i<=n; ++i)
	{
		if (prime[i])
		{
			s[i].insert(i);			
			for (ld j=2*i; j<=n; j+=i)
			{
				prime[j] = false;
				s[j].insert(i);
			}
		}
	}
}
#define forn(i,e) for(int i = 0; i < e; i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define reprev(i,a,b) for(i=a;i>=b;i--)

#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
#define sp cout<<" "
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
ld gcd(ld a, ld b) { if(b == 0) return a; return gcd(b, a % b); }
ld fastpowMOD(ld a, ld p,ld MOD){ if(p==0) return 1; ld z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
ld fastpow(ld a, ld p){ if(p==0) return 1; ld z = fastpow(a,p/2); z = (z*z); if(p%2) z = (z*a); return z; }
ld a,b;

ld search1(ld a[], ld f,ld n)
{
	ld left=1;
	ld right=n+1;
	while(right-left>1)
	{
		ld mid = left + (right-left)/2;
		if(a[mid]<f)
		{
			left=mid;
		}
		else right=mid;
	}
	return a[left];
}
ld p = 1000000007;
ld ar[100+4];
ld dp[104][100004];
ld dpsum[104][100004];

int main(){
	ld n,k,i,j;
	cin >> n >> k;
	REP(i,1,n)cin >> ar[i];
	ar[0]=0;
	memset(dp,0,sizeof(dp));
	memset(dpsum,0,sizeof(dpsum));
	REP(i,0,k)
	{
		dpsum[0][i]=1;
	}
	dp[0][0]=1;
	REP(i,1,n)
	{
		dp[i][0]=1;
		dpsum[i][0]=1;
		REP(j,1,k)
		{
			ld mini = max((ld)1, j - ar[i]);
			dp[i][j]=(dpsum[i-1][j]-dpsum[i-1][mini-1] + p)%p;
			if(j-ar[i]<1)
			{
				 dp[i][j] = (dp[i][j] + dpsum[i - 1][mini - 1])%p;
			}
			dp[i][j]=(dp[i][j]+p)%p;
			dpsum[i][j]=(dpsum[i][j-1]+dp[i][j])%p;
		}
	}
	cout << dp[n][k] << endl;
	return 0;
}

/*
ld getx(ld a,ld k,ld n)
{
	ld i,j;
	if(dp[a][k]!=0)return dp[a][k];
	REP(i,0,ar[a])
	{
		if(i>k)break;
		ld f = getx(a-1,k-i,n);
		if(f==-1)continue;
		dp[a][k]=(dp[a][k]+f)%p;
	}
	if(dp[a][k]==0)dp[a][k]=-1;
	return dp[a][k];
}*/


Measured memory_bytes: 168320