#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define mod 1000000007
#define PI 3.14159265358979323
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define debug(x) cout<<"Case "<<x<<": "
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/
	//Did not understood this much
	ll n,k;
	cin>>n>>k;
	ll a[n+5]={0};
	ll dp[k+5]={0};
	dp[0]=1;
	//dp[i] - the numbert of ways such that we have used i candies so far
	rep(i,n)cin>>a[i];
	rep(child,n)
	{
		vll fake(k+1);
		fd(used,k,0)
		{
			ll temp = dp[used];
			ll L = used+1;
			ll R = used+min(a[child],k-used); 
			if(L<=R)
			{
				fake[L]=(fake[L]+temp)%mod;
				if(R+1<=k)
					fake[R+1]=(fake[R+1]-temp)%mod;
			}
		}
		ll prefixSum=0;
		rep(i,k+1)
		{
			prefixSum=(prefixSum+fake[i])%mod;
			dp[i]=(dp[i]+prefixSum)%mod;
		}
	}
	cout<<dp[k]<<endl;
}
