#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main() {
	int n,k,i;
	cin>>n>>k;
	int a[n+1];
	for(i=1;i<=n;i++)
	cin>>a[i];
	int dp[n+1][k+1]={0};
	for(i=1;i<=n;i++)
	{
		vector<int>sum(k+1);
		sum[0]=dp[i-1][0];
		for(int j=1;j<=k;j++)
		sum[j]=sum[j-1]+dp[i-1][j]%mod;	
		for(int j=1;j<=k;j++)
		{
			if(j<=a[i])
			dp[i][j]=sum[j];
			else 
			{
				int m=j-a[i]-1;
				dp[i][j]=(sum[j]-sum[m]+mod)%mod;
			}
		}
		
	}
	cout<<dp[n][k]<<endl;
	return 0;
}