#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define vec vector<int,int> 
#define int long long 
#define pii pair<int,int>

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//ios_base& scientific (ios_base& str);
	
	int t=1;
	//cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		int arr[n];
		rep(i,n) cin>>arr[i];
		int dp[k+1]={0};
		int pre_sum[k+1]={0};
		rep(i,n){
			rep(j,k+1){
				if(j==0) {dp[j]=1; continue;}
				if(i==0){
					if(j<=arr[i]) dp[j]=1;
					else{
						dp[j]=0;
					}
				}
				else{
				dp[j]=pre_sum[j]%mod;
				if(j>=arr[i]+1){
					dp[j]=(dp[j]%mod-pre_sum[j-arr[i]-1]%mod);
					dp[j]%=mod;
				}
				dp[j]%=mod;}
			}
			pre_sum[0]=dp[0]%mod;
			for(int j=1;j<=k;j++){
				pre_sum[j]=(pre_sum[j-1]%mod+dp[j]%mod)%mod;
				pre_sum[j]%=mod;
			}
		}
		cout<<dp[k]%mod<<endl;
	}
	//exit();
	return 0;
}
