#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 1e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second

#define err(n) cout<<n<<" ";
#define t1 cout<<",";

 ll MOD= 1e9 +7;

void add_self (ll& a, ll b){
	a+= b;
	if(a>MOD)a-=MOD;
}

void sub_self (ll& a, ll b){
	a-=b;
	a= ((a%MOD)+MOD)%MOD;
}

int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k;
ll f;

ll n;cin>>n>>k;
ll dp[k+4]={0};
dp[0]=1;
repup(0,n-1,i){
	ll b[k+2]={0};
	
	ll x;
	cin>>x;
	repdown(0, k,j){
		sub_self(b[j+ min(k-j,x)+1], dp[j]);
		add_self (b[j+1],dp[j]);
	}
	repup(1,k+1,j){
		add_self(b[j],b[j-1]);
		add_self(dp[j-1], b[j-1]);
	}
}
cout<<dp[k];

}