
#include "bits/stdc++.h"

using namespace std;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define sd(x) scanf("%lld",&x)
#define pds(x) printf("%lld ", x)
#define large 100005
#define MOD 1000000007
#define dd double
#define pb push_back
#define mk make_pair
#define rep0(i,b) for(int i=0;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define pll pair<ll, ll>
#define ld long double
#define vll vector<ll>
#define vpll vector<pll>
#define sortv(v) sort(v.begin(),v.end()) 

// Debugging
#define d1(var1) std::cout<<#var1<<" : "<<var1<<"\n"
#define d2(var1, var2) std::cout<<#var1<<" : "<<var1<<"\n"<<#var2<<" : "<<var2<<"\n"
#define d3(var1, var2, var3) std::cout<<#var1<<" : "<<var1<<"\n"<<#var2<<" : "<<var2<<"\n"<<#var3<<" : "<<var3<<"\n"

// Output variables in a single line separated by space
#define o1(a) cout<<a<<"\n"
#define o2(a, b) cout<<a<<" "<<b<<"\n"
#define o3(a, b, c) cout<<a<<" "<<b<<" "<<c<<"\n"

// Input variables
#define i1(a) cin>>a
#define i2(a, b) cin>>a>>b
#define i3(a, b, c) cin>>a>>b>>c

// self max function
template <typename T> void chmax(T& a, T b) {
    a = max(a, b);
}

// Self min function
template <typename T> void chmin(T& a, T b) {
    a = min(a, b);
}

// Generic swap function
template <class X> void swp(X &a, X &b) {
	X c;
	c = a;
	a = b;
	b = c;
}

using ll = long long int;
using ull = unsigned long long int;

ll ModE(ll x, ull y, ll p = MOD) 
{ 
    ll res = 1;
    x = x % p;    
    while (y > 0) 
    {   if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
}

int main() {
    #ifdef M_DEBUG
    //freopen("input.txt", "r", stdin);
    //freopen("`output.txt", "w", stdout);
    #endif

    fastio
    
	//ll T; cin>>T; while(T--) {}
	
	ll n, k;
	i2(n, k);
	
	ll dp[n + 1][k + 1];
	rep2(i, 0, k)
		dp[0][i] = 0;

	dp[0][0] = 1;
	
	int p;
	for(int i = 1; i <= n; i++){
		i1(p);
		ll arr[k + 1] = {0};
		
		arr[0] = dp[i - 1][0];
		for(int j = 1; j <= k; j++)
			arr[j] = (arr[j - 1] + dp[i - 1][j]) % MOD;
			
		for(int j = 0; j <= k; j++){
			dp[i][j] = 0;
			int L = max(0, j - p);
			int R = min(p, j);
			
			dp[i][j] = (dp[i][j] + arr[R]) % MOD;
			if(L > 0)
				dp[i][j] = (dp[i][j] - arr[L - 1] + MOD) % MOD;
			 //for(int l = 0; l <= min(p, j) && j - l >= 0; l++){
				//dp[i][j] += dp[i-1][j - l];
			 //}
		}
	}
	
	cout<<dp[n][k];
    return 0;
}

