#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll INF = 5e15;
const ll MOD = 1e9 + 7;
template <typename T>
class SegmentTree {
 public:
  ll size;
  vector<T> node;
  T identity_ele;
  function<T(T, T)> comp;
  SegmentTree(const vector<T> &v, function<T(T, T)> comp, T identity_ele) {
    ll tmp = 1;
    while (tmp < v.size()) tmp = (tmp << 1);
    this->size = tmp;
    this->identity_ele = identity_ele;
    this->comp = comp;
    node.resize(2 * size - 1);
    for (ll i = 0; i < v.size(); i++) {
      node[i + size - 1] = v[i];
    }
    for (ll i = size - 2; 0 <= i; i--) {
      node[i] = comp(node[i * 2 + 1], node[i * 2 + 2]);
    }
  }
  void update(ll pos, T value) {
    pos += size - 1;
    node[pos] = value;
    while (pos > 0) {
      pos = (pos - 1) / 2;
      node[pos] = comp(node[2 * pos + 1], node[2 * pos + 2]);
    }
  }
  T query(ll a, ll b) { return subQuery(a, b, 0, 0, size); }
  T subQuery(ll a, ll b, ll k, ll l, ll r) {
    if (r <= a || b <= l) {
      return identity_ele;
    } else if (a <= l && r <= b) {
      return node[k];
    } else {
      T left = subQuery(a, b, k * 2 + 1, l, (l + r) / 2);
      T right = subQuery(a, b, k * 2 + 2, (l + r) / 2, r);
      return comp(left, right);
    }
  }
};
int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll &a : A) cin >> a;
  SegmentTree<ll> ST(
      vector<ll>(K + 1, 0), [](ll a, ll b) { return (a + b) % MOD; }, 0);
  ST.update(0, 1);
  for (ll i = 0; i < N; i++) {
    vector<ll> tmp(K + 1);
    for (ll j = 0; j <= K; j++) {
      ll left = max<ll>(0, j - A[i]);
      ll right = j + 1;
      tmp[j] = ST.query(left, right);
    }
    ST = SegmentTree<ll>(
        tmp, [](ll a, ll b) { return (a + b) % MOD; }, 0);
  }
  cout << ST.query(K, K + 1) << endl;
  return 0;
}
