#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using vl = vector<ll>;                   //   | grep -v ' .* '  1300111 ~2^20.31
using vvl = vector<vl>;                  //                    10300777 ~2^23.30
using pll = pair<ll,ll>;                 //                   100400999 ~2^26.58
using vb = vector<bool>;                 //                  1300400999 ~2^30.28
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //                 10200500333 ~2^33.25
const double eps = 1e-9;                 //                100200400777 ~2^36.54
#define sz(c) ll((c).size())             //               1200300700111 ~2^40.13
#define all(c) begin(c),end(c)           //              10200300500777 ~2^43.21
#define mp make_pair                     //             100200300400777 ~2^46.51
#define mt make_tuple                    //            1200300400600999 ~2^50.09
#define pb push_back                     //           10200300400600111 ~2^53.18
#define eb emplace_back                  //          100200300400600333 ~2^56.48
#define xx first                         //         1200300400500800999 ~2^60.06
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i>=(a); i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll n_children, n_candies;
vl children;
vvl dp;
ll mod_n = 1000000007;

ll get_possibilities(ll index_c, ll candies_left){
   
    if(candies_left < 0){
        return 0;
    }
    if(candies_left == 0){
        return 1;
    }
    if(index_c == n_children-1){
        if(candies_left <= children[index_c]){
            return 1;
        }
        else {
            return 0;
        }
    }
    if(dp[index_c][candies_left] != -1) {
        return dp[index_c][candies_left];
    }
    ll res = 0;
    FOR(i, 0, children[index_c]+1){
        res += get_possibilities(index_c+1, candies_left-i);
        res = res % mod_n;
    }
    dp[index_c][candies_left] = res;
    return res;
}

int main() {

    cin >> n_children >> n_candies;
    children.resize(n_children);
    FOR(i, 0, n_children){
        cin >> children[i];
    }
    if(n_candies == 0){
        cout << 1 <<endl;
        return 0;
    }
    dp.assign(n_children, vl(n_candies+1, -1));
    
    FOR(i, 0, n_children){
        dp[i][0] = 1;
    }

    FOR(i, 1, n_candies+1){
        dp[0][i] = dp[0][i-1];
        if(i <= children[0]) {
            dp[0][i] = (dp[0][i] + 1) % mod_n;
        }
    }

    FOR(child, 1, n_children){
        FOR(cand, 1, n_candies+1){
            dp[child][cand] = dp[child][cand-1];
            dp[child][cand] += dp[child-1][cand];
            if(cand - children[child] > 0){
                dp[child][cand] -= dp[child-1][cand-children[child]-1];
            } 
            dp[child][cand] = dp[child][cand] % mod_n;
        }
    }

    cout << (dp[n_children-1][n_candies] - dp[n_children-1][n_candies-1] + mod_n) % mod_n << endl;

    return 0;
}



Measured memory_bytes: 79360