#include<bits/stdc++.h>
using namespace std;
#define M 1000000007;
int main()
{
	long long int n,k,i,j;
	cin>>n>>k;
	long long int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];


	long long int dp[2][k+1],b[k+1]={};
	memset(dp,0,sizeof(dp));
	b[0]=1;
	for(i=0;i<n;i++)
	{
		for(j=0;j<=k;j++)
		{
			if(i==0)
			{
				if(j<=a[i])
					dp[(i%2)][j]=1;
				continue;
			}
			else if(j==0)
			{
				dp[(i%2)][j]=1;
				continue;
			}
			b[j]=(b[j-1]+dp[((i-1)%2)][j])%M;
			if(j<=a[i])
				dp[(i%2)][j]=b[j];
			else
				dp[(i%2)][j]=(b[j]-b[j-a[i]-1]);
		}
	}
	cout<<dp[((n-1)%2)][k]<<endl;

}
