
    #include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define endl "\n"
    #define ll long long int
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define f first
    #define s second
    
    using namespace std;
    void add_self(ll& a,ll b)
    {
        a+=b;
        if(a>=mod)
            a-=mod;
        return;
    }
    void sub_self(ll& a,ll b)
    {
        a-=b;
        if(a<0)
            a+=mod;
        return;
    }
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T=1;
        //cin>>T;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            ll n,k;
            cin>>n>>k;
            ll dp[k+1];
            dp[0]=1;
            ll upto;
            for(ll child=0;child<n;child++)
            {
                cin>>upto;
                ll pre[k+1]={0};
                for(ll used=k;used>=0;used--)
                {
                    ll l=used+1;
                    ll r=used+min(upto,k-used);
                    if(l<=r)
                    {
                        add_self(dp[l],dp[used]);
                        if(r+1<=k)
                            sub_self(dp[r+1],dp[used]);
                    }   
                }
                ll pref=0;
                for(ll i=0;i<=k;i++)
                {
                    add_self(pref,pre[i]);
                    add_self(dp[i],pref);
                }
            }
            cout<<dp[k];
        }
        return 0;
    }
