#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 
#define inp 20
#define check exit(0)
#define nl cout<<endl;
#define mod 1000000007 
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define deb(v) for(int i=0;i<v.size();i++) {cout<<v[i]; (i==v.size()-1) ? cout<<"\n":cout<<" "; }
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ordered_set tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace __gnu_pbds;
using namespace std;
 
// Errichto ... ;)

void md(ll &a)
{
    a%=mod;
}
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
void sub_self(int& a, int b) {
    a -= b;
    if(a < 0) {
        a += mod;
    }
}

int main()
{
    jaldi

    int n,k;
    cin>>n>>k;
    vector<int> dp(k+1,0);
    dp[0]=1;

    for(int child=1;child<=n;child++)
    {
        int upto;
        cin>>upto;

        vector<ll> tmp(k+2,0);
        for(int ubho=k;ubho>=0;ubho--)
        {
            int toadd=dp[ubho];
            int l=ubho+1;
            int r=ubho+min(upto,k-ubho);
            if(l<=r)
            {
                tmp[l]+=toadd;
                tmp[r+1]-=toadd;
            }
        }
        int ps=0;
        for(int i=0;i<=k;i++)
        {
            ps+=tmp[i];
            ps%=mod;
            dp[i]+=ps;
            dp[i]%=mod;
            // add_self(ps,tmp[i]);
            // add_self(dp[i],ps);
        }
    }
    cout<<dp[k];

    return 0;
}