#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+5];
	memset(dp,0,sizeof(dp));
	dp[0]=1;

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

		vector<ll> diff(k+5,0);

		for(ll j=k-1;j>-1;j--)
		{
			ll val=dp[j];

			ll l=j+1,r=min(k,j+x);

		diff[l]=(diff[l]+val)%mod;
	    diff[r+1]=(mod +diff[r+1]-val)%mod;
		}

		ll pre=0;

		for(ll i=0;i<=k;i++)
		{
			pre=(pre+mod+diff[i])%mod;
			dp[i]=(dp[i]+pre+mod)%mod;
		}
		
	}
	cout<<dp[k]<<endl;
}
