#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include <unordered_map> 
#include<vector>
#include<queue>
#include<set>
#include <bits/stdc++.h> 
#include<string>
#define N 2005
#define K 200005
#define MOD 1e9+7
#define ll long long int
using namespace std;

int main(){
	ll n,k;
	cin>>n>>k;
	ll dp[k+1] = {0};
	dp[0] = 1;
	ll x;
	for(ll i=0;i<n;i++){	//implicitly keeps track of the number of the ppl who are there
		cin>>x;
		vector<int> fake(k+1);
		for(ll candies = k;candies>=0;candies--){
		    ll left = candies +1;
		    ll r = min(candies+x,k);
		    ll temp = dp[candies];
		    
		    if(left<=r ){
		    	fake[left] += temp;
		    	if(r<k)
		    	    fake[r+1] += -1*temp;
		    }
			/*for(lli =l;i <=r;i++){//adding a fixed value to some terms; which is dp[candies] and this value never gets changed as to change dp[candies] last should be ==0 which is not the case
				dp[i] +=dp[candies];
				if(dp[i] >=MOD)
					dp[i] -=MOD;
			}*/
		}
		ll prefix = 0;
		for(ll i=0;i<=k;i++){
			prefix+=fake[i];
			dp[i]+=prefix;
			if(dp[i] > MOD)
			    dp[i]-=MOD;
		}
	}
	/*
	cout<<dp[0]<<endl;
	cout<<dp[1]<<endl;
	cout<<dp[2]<<endl;
	cout<<dp[3]<<endl;
	cout<<dp[4]<<endl;
	*/
	cout<<dp[k];
}	
