#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.first << ", " << p.second << ")";
}
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  for (int i = 0; ((0 < int(v.size()) ? 1 : -1) < 0) ? i > int(v.size())
                                                     : i < int(v.size());
       i += (0 < int(v.size()) ? 1 : -1))
    o << setw(7) << v[i];
  return o << "\033[0m" << '\n' << "\033[48;5;196m\033[38;5;15m";
}
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
template <class T, class... Ts>
void debug(const T &e, const Ts &...r) {}
void _main(int tc) {
  int n, K;
  cin >> n >> K;
  vector<int> v(n);
  for (int i = 0; ((0 < n ? 1 : -1) < 0) ? i > n : i < n; i += (0 < n ? 1 : -1))
    cin >> v[i];
  int mod = 1e9 + 7;
  vector<vector<int>> mem(n + 1, vector<int>(K + 1));
  for (int i = 0; ((0 < n + 1 ? 1 : -1) < 0) ? i > n + 1 : i < n + 1;
       i += (0 < n + 1 ? 1 : -1))
    mem[i][K] = 1;
  for (int i = n - 1; i >= 0; i--) {
    vector<int> pref = mem[i + 1];
    for (int used = 1; ((1 < K + 1 ? 1 : -1) < 0) ? used > K + 1 : used < K + 1;
         used += (1 < K + 1 ? 1 : -1)) {
      pref[used] = (pref[used] + pref[used - 1]) % mod;
    }
    for (int used = K; ((K < -1 ? 1 : -1) < 0) ? used > -1 : used < -1;
         used += (K < -1 ? 1 : -1)) {
      int ans = 0;
      int Left = used;
      int Right = used + min(v[i], K - used);
      ans = pref[Right];
      if (Left > 0) ans -= pref[Left - 1];
      mem[i][used] = ans;
    }
  }
  if (mem[0][0] < 0) mem[0][0] += mod;
  cout << mem[0][0] << '\n';
}
int main() {
  _main(0), exit(0);
  int tc;
  cin >> tc;
  for (int i = 0; ((0 < tc ? 1 : -1) < 0) ? i > tc : i < tc;
       i += (0 < tc ? 1 : -1))
    _main(i + 1);
}
