#include <bits/stdc++.h>
template <typename T>
class SegmentTreeUpdAdd {
 public:
  int n;
  std::vector<T> node;
  SegmentTreeUpdAdd(std::vector<T> v) {
    int sz = v.size();
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n, 0);
    for (int i = 0; i < sz; ++i) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; --i)
      node[i] = node[2 * i + 1] + node[2 * i + 2];
  }
  void update(int idx, T val) {
    assert(0 <= idx && idx < n);
    node[idx + n - 1] = val;
    idx = idx + n - 1;
    while (idx > 0) {
      idx = (idx - 1) / 2;
      node[idx] = node[2 * idx + 1] + node[2 * idx + 2];
    }
  }
  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) {
      return 0;
    }
    if (a <= l && r <= b) return node[k];
    T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
    T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
    return vl + vr;
  }
  T query(int a, int b) { return query(a, b, 0, 0, n); }
};
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll << 50;
template <typename T>
void printv(const vector<T>& s) {
  for (int i = 0; i < (int)(s.size()); ++i) {
    cout << s[i];
    if (i == (int)(s.size()) - 1)
      cout << endl;
    else
      cout << " ";
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int n, K;
  cin >> n >> K;
  vi a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  SegmentTreeUpdAdd<ll> st(vector<ll>(K + 1));
  st.update(K, 1);
  int sz = st.n;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= K; ++j) {
      int l = j, r = j + a[i] + 1;
      l = max(0, l);
      r = min(K + 1, r);
      ll tmp = st.query(l, r);
      st.update(j, tmp % MOD);
    }
  }
  cout << st.node[sz - 1] << endl;
}
