#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
using namespace std;
#define int ll

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n,k;
	cin>>n>>k;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	int dp[k+1][n+1];
	for(int i=0;i<=k;i++)
		for(int j=0;j<=n;j++)
			dp[i][j]=0;
	
	for(int i=0;i<=k;i++)
		dp[i][0]=0;
	for(int i=0;i<=min(k,a[0]);i++)
		dp[i][1]=1;
	for(int i=2;i<=n;i++)
	{
		dp[0][i]=1;
		int su=1;
		for(int j=1;j<=k;j++)
		{
			su+=dp[j][i-1];
			if(j>a[i-1])
				su-=dp[j-a[i-1]][i-1];
			su%=mod;
			su=(su+mod)%mod
			dp[j][i]=su;
			//cout<<dp[j][i]<<' ';
		}
		//cout<<endl;
	}
	cout<<(dp[k][n]%mod+mod)%mod<<endl;
}