#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define endl '\n'
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;


int32_t main(){
    vaibhavv06;
	int n,k; cin>>n>>k;
    int dp[k+1]={0};
    dp[0]=1;
    for(int child = 0;child<n;child++){
        int upto; cin>>upto;
        int fake[k+1]={0};
        for(int used=k;used>=0;used--){
            int temp = dp[used];
            int l = used+1;
            int r = used + min(upto,k-used);
            if(l<=r){
                fake[l]+=temp;
                fake[l]%=MOD;
                if(r+1<=k){
                    fake[r+1]-=temp;
                    fake[r+1]%=MOD;
                }
            }
        }
        int prefix = 0;
        for(int i=0;i<=k;i++){
            prefix+=fake[i];
            prefix%=MOD;
            dp[i]+=prefix;
            dp[i]%=MOD;
        }
    }
    cout<<dp[k]%MOD<<endl;
}