#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod= 1e9+7;
const ll INF= 1e18L+5;

int main() {
	ll n,k;
	cin >> n >> k;
	ll a[n];
	ll dp[k+1] = {0};
	dp[0]=1;
		
	for(ll i=0; i<n; i++){
		cin >> a[i];
		ll temp[k+1] = {0};
	
		for(ll used = k; used>=0; used--){
			ll l = used+1;
			ll r = used+min(a[i],k-used);
			if(l<=r){
				temp[l] = (temp[l]+dp[used])%mod;
				if(r<k)
					temp[r+1] = (temp[r+1]-dp[used])%mod;
			}
			// for(ll j=l; j<=r && j<=k; j++){
			// 	dp[j] = (dp[used]+dp[j])%mod;
			// }
		}
		// ll sum = 0;
		for(ll j=0;j<=k; j++){
			temp[j] = j==0 ? temp[j] : (temp[j]+temp[j-1])%mod;
			dp[j] = (dp[j]+temp[j])%mod;
			// sum = (sum + temp[i])%mod;
			// dp[i] = (dp[])
		}
	}
	cout<<dp[k]<<endl;
}