#include <bits/stdc++.h>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
template <ostream& out = cout, class... T>
void prints(T&&...) {}
template <ostream& out = cout, class... T>
void printe(T&&...) {}
template <ostream& out = cout, class... T>
void printw(T&&...) {}
template <ostream& out = cout, class... T>
void printew(T&&...) {}
template <ostream& out = cout, class... T>
void printb(T&&...) {}
template <ostream& out = cout, class... T>
void printd(T&&...) {}
template <ostream& out = cout, class... T>
void printde(T&&...) {}
template <ostream& out = cout, class... T>
void printdu(T&&...){};
template <class S, class T>
istream& operator>>(istream& in, pair<S, T>& p) {
  return in >> p.first >> p.second;
}
template <class T>
istream& operator>>(istream& in, vector<T>& v) {
  for (auto& e : v) {
    in >> e;
  }
  return in;
}
template <class T>
struct SegTreeT {
  SegTreeT *l, *r;
  int left, right;
  T value = 0;
  SegTreeT(vector<T>& data) : SegTreeT(0, data.size() - 1, data) {}
  SegTreeT(int st, int lt, vector<T>& data) : left(st), right(lt) {
    if (left == right) {
      l = r = nullptr;
      value = data[left];
    } else {
      l = new SegTreeT(left, (right - left) / 2 + left, data);
      r = new SegTreeT((right - left) / 2 + left + 1, right, data);
    }
  }
  void add(int st, int lt, T val) {
    if (right < st || lt < left) {
      return;
    }
    if (st <= left && right <= lt) {
      value += val;
    } else {
      l->add(st, lt, val);
      r->add(st, lt, val);
    }
  }
  T getVal(int idx) {
    if (right < idx || idx < left) {
      return 0;
    }
    return value + (l ? l->getVal(idx) + r->getVal(idx) : 0);
  }
};
using SegTree = SegTreeT<ll>;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<vector<ll>> dp(n + 1, vector<ll>(k + 1));
  vector<ll> data(k + 1);
  SegTree st(data);
  st.add(0, 0, 1);
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    SegTree next(data);
    for (int j = 0; j <= k; j++) {
      ll num = st.getVal(j) % M;
      next.add(j, min(k, j + a), num);
    }
    st = next;
  }
  cout << st.getVal(k) % M << '\n';
}
