#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

constexpr int MOD = 1'000'000'007;

LL dp(VVI &memo, VI &a, int n, int k) {
    if (k == 0) return 1;
    if (n == 0) return 0;
    if (memo[n][k]) return memo[n][k];
    LL ret = 0;
    REP(i,0,a[n-1]+1) {
        if (k - i < 0) break;
        ret += dp(memo, a, n - 1, k - i);
        if (ret >= MOD) ret -= MOD;
    }
    return memo[n][k] = ret;
}

void solve() {
    int n,k;
    cin >> n >> k;
    VI a(n);
    REP(i,0,n) cin >> a[i];
    VVI memo(n+1,VI(k+1));
    cout << dp(memo, a, n, k) << endl;
}

int main() {
    solve();
    
    return 0;
}