#include <bits/stdc++.h>
typedef long long int ll;
const ll MOD = 1000000007;
using namespace std;
int main(){
    vaibhavv06;
	int n,k; cin>>n>>k;
    vector<int> dp(k+1);
    dp[0]=1;
    for(int child = 0;child<n;child++){
        int upto; cin>>upto;
       
        vector<int> fake(k+1);
        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;
                if(fake[l]>MOD) fake[l]-=MOD;
                if(r+1<=k){
                    fake[r+1]-=temp;
                    if(fake[r+1]<0) 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]<<endl;
}
