#include <bits/stdc++.h>
#include <numeric>
#define M 1000000007
#define inf 1e18+1
#define pb push_back
// #define mp make_pair
#define forz(i,s,n) for(lli i=s;i<n;i++)
#define fore(i,n,s) for(lli i=n;i>=s;i--)
#define binod ios_base ::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);


#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

typedef long long int lli;
//typedef pair<long long int, long long int> pll;
typedef unsigned long long int ull;
using namespace std;

lli recpow(lli x, lli n, lli mod)
{
    if (n == 0)
        return 1;
    else if (n % 2 == 0) //n is even
        return recpow((x * x) % mod, n / 2, mod);
    else //n is odd
        return (x * recpow((x * x) % mod, (n - 1) / 2, mod)) % mod;
}


//code begins here
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    binod
    //sieve();
    lli n,k;
    cin>>n>>k;
    lli a[n];
    forz(i,0,n)
    cin>>a[i];

    lli dp[k+1]={0};
    dp[0]=1;
    for(int i=0;i<n;++i)
    {
        lli pref[k+1]={0};
        for(int j=k;j>=0;--j)
        {
            lli tmp=dp[j];
            lli l=j+1, r=j+min(k-j,a[i])+1;
            pref[l]=(pref[l]+tmp)%M;
            if(r<=k)
            pref[r]=(pref[r]-tmp+M)%M;
            // for(int l=1;l<=min(k-j,a[i]);++l)
            // dp[j+l]=(dp[j+l]+dp[j])%M;
        }
        lli ps = 0;
        forz(i, 0, k + 1)
        {
            ps = (ps + pref[i]) % M;
            dp[i] = (dp[i] + ps) % M;
        }
    }
    
    cout<<dp[k];

    return 0;
}