#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
class SegmentTree {
 private:
  vector<int> _tree;
  int _n_max;
  int _initial_value;
  function<int(int&, int&)> _binary_operator;
  int _query(int a, int b, int i, int j, int depth) {
    if (a >= j or b <= i) return _initial_value;
    if (a <= i and j <= b) return _tree[depth];
    int vl = _query(a, b, i, (i + j) / 2, depth * 2 + 1);
    int vr = _query(a, b, (i + j) / 2, j, depth * 2 + 2);
    return _binary_operator(vl, vr);
  }

 public:
  SegmentTree(int n, int initial_value,
              function<int(int&, int&)> binary_operator)
      : _initial_value(initial_value), _binary_operator(binary_operator) {
    int m = log2(n);
    _n_max = m == log2(n) ? n : 1 << (m + 1);
    _tree.resize(_n_max * 2 - 1, _initial_value);
  }
  void update(int i, int x) {
    i += _n_max - 1;
    _tree[i] = x;
    while (i > 0) {
      i = (i - 1) / 2;
      _tree[i] = _binary_operator(_tree[i * 2 + 1], _tree[i * 2 + 2]);
    }
  }
  int query(int a, int b) { return _query(a, b, 0, _n_max, 0); }
  void show() {
    int depth = 0;
    for (int i = 0; i < (int)(_tree.size()); ++i) {
      cerr << _tree[i] << " ";
      if (i == ((1 << (depth + 1)) - 2)) {
        cerr << '\n';
        depth++;
      }
    }
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<SegmentTree> st(n + 1, SegmentTree(k + 1, 0, [](int lhs, int rhs) {
                           return ((long long)lhs + (long long)rhs) % MOD;
                         }));
  for (int i = 0; i < (int)(n); ++i) cin >> a[i];
  st[0].update(0, 1);
  for (int i = (1); i <= (int)(n); ++i)
    for (int j = (0); j <= (int)(k); ++j)
      st[i].update(j, st[i - 1].query(max(j - a[i - 1], 0), j + 1));
  cout << st[n].query(k, k + 1) << '\n';
  return 0;
}
