#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;

int main()
{ 
	ll n,k,x;
	cin>>n>>k;

	ll dp[k+1];
	memset(dp,0,sizeof(dp));
	dp[0]=1;

	for(ll i=0;i<n;i++)
	{
		cin>>x;

		vector<ll> pre(k+1,0);
		pre[0]=1;

		for(ll j=1;j<=k;j++)
			pre[j]=(pre[j-1]+dp[j])%mod;

		for(ll j=0;j<=k;j++)
		{
			ll z=pre[j];

			if(j-x>=1)
			z=(z-pre[j-x-1]+mod)%mod;

			dp[j]=z;
		}
	}
	cout<<dp[k]<<endl;
}
