#include <bits/stdc++.h>
#define ll long long
using namespace std;

const ll int INF = 1e18 + 5;

int main(int argc, char const *argv[])
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n,k;
    cin>>n>>k;
    ll int a[n];
    for(ll int i=0;i<n;i++){
    	cin>>a[i];
    }
    ll int dp[n][k+1] = {0};
    ll int MOD = 1e9 + 7;
    ll int dp1[n][k+1];
    for(ll int i=0;i<n;i++){
    	for(ll int o = 0;o<=k;o++){
    		dp[i][o] = 0;
    		dp1[i][o] = 0;
    		ll int zero = 0;
    		if(i == 0 || o == 0)
    			dp[i][min(o,a[i])] = 1;
    		else{
    			if(o>=min(a[i]+1,k+1)){
    				dp[i][o] = (dp1[i-1][o] - dp1[i-1][o-min(a[i]+1,k+1)])%MOD;
    			}
    			else
    				dp[i][o] = dp1[i-1][o]; 
    		}
    		dp1[i][o] = (dp[i][o] + dp1[i][max(o-1,zero)])%MOD;
	    }
    }
    cout<<dp[n-1][k];
	return 0;
}