#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const long long MOD = 1e9 + 7;
double EPS = 1e-8;
template <typename T>
struct SegTree {
  int n;
  vector<T> dat, lazy;
  vector<int> width;
  T NIL = 0;
  T DFLT;
  SegTree(int n_, const T& initV, const T& dflt) : DFLT(dflt) {
    n = 1;
    while (n < n_) n *= 2;
    dat.assign(2 * n - 1, initV);
    lazy.assign(2 * n - 1, NIL);
    width.assign(2 * n - 1, 0);
    width[0] = n;
    for (int i = (0); i < (int)(width.size()); i++) {
      int k = i * 2 + 1;
      if (k >= width.size()) continue;
      width[k] = width[i] / 2;
      width[k + 1] = width[i] / 2;
    }
  }
  void add(int l, int r, const T& t) { add(l, r, t, 0, 0, n); }
  T query(int l, int r) { return query(l, r, 0, 0, n); }

 private:
  T f(const T& a, const T& b) { return (a + b) % MOD; }
  void fix(int k) { dat[k] = f(dat[k * 2 + 1], dat[k * 2 + 2]); }
  void setLazy(int k, const T& v) {
    (lazy[k] += v) %= MOD;
    (dat[k] += v * width[k]) %= MOD;
  }
  void push(int k) {
    if (lazy[k] == NIL) return;
    setLazy(k * 2 + 1, lazy[k]);
    setLazy(k * 2 + 2, lazy[k]);
    lazy[k] = NIL;
  }
  void add(int queryL, int queryR, const T& val, int k, int nodeL, int nodeR) {
    if (nodeR <= queryL || queryR <= nodeL) {
      return;
    }
    if (queryL <= nodeL && nodeR <= queryR) {
      setLazy(k, val);
      return;
    }
    push(k);
    int nodeM = (nodeL + nodeR) / 2;
    add(queryL, queryR, val, k * 2 + 1, nodeL, nodeM);
    add(queryL, queryR, val, k * 2 + 2, nodeM, nodeR);
    fix(k);
  }
  T query(int queryL, int queryR, int k, int nodeL, int nodeR) {
    if (nodeR <= queryL || queryR <= nodeL) {
      return DFLT;
    }
    if (queryL <= nodeL && nodeR <= queryR) {
      return dat[k];
    }
    push(k);
    int nodeM = (nodeL + nodeR) / 2;
    T vector<long long> = query(queryL, queryR, k * 2 + 1, nodeL, nodeM);
    T vr = query(queryL, queryR, k * 2 + 2, nodeM, nodeR);
    return f(vector<long long>, vr);
  }
};
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = (0); i < (int)(n); i++) cin >> a[i];
  SegTree<long long> dp(2 * k + 2, 0LL, 0LL);
  dp.add(0, 1, 1LL);
  for (int i = (0); i < (int)(n); i++) {
    for (int l = k; l >= 0; --l) {
      auto x = dp.query(l, l + 1);
      dp.add(l + 1, l + a[i] + 1, x);
    }
  }
  cout << dp.query(k, k + 1) << endl;
  return 0;
}
