#include <bits/stdc++.h>
template <typename T>
class BIT {
  int sz;

 public:
  std::vector<T> node;
  BIT(int sz) : sz(sz + 1), node(std::vector<T>(sz + 1, 0)) {}
  void add(int idx, T val) {
    ++idx;
    assert(0 < idx && idx < sz);
    while (idx < sz) {
      node[idx] += val;
      idx += idx & -idx;
    }
  }
  T sum(int idx) {
    ++idx;
    assert(0 < idx && idx < sz);
    T res = 0;
    while (idx > 0) {
      res += node[idx];
      idx -= idx & -idx;
    }
    return res;
  }
};
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];
  }
  BIT<ll> bit(K + 1);
  bit.add(K, 1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < K; ++j) {
      int l = j, r = j + a[i];
      l = max(0, l);
      r = min(K, r);
      ll tmp = bit.sum(r) - bit.sum(l);
      bit.add(j, tmp % MOD);
    }
  }
  cout << bit.sum(0) << endl;
}
