#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;
template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}
template <typename T>
class FenwickTree {
  const int n;
  vector<T> data;

 public:
  FenwickTree(int count) : n(count), data(count, 0) { ; }
  void add(int pos, const T &value) {
    assert(0 <= pos && pos < n);
    for (int i = pos; i < n; i |= i + 1) {
      data[i] += value;
      data[i] %= MOD;
    }
  }
  T sum(int pos) const {
    assert(0 <= pos && pos <= n);
    T res = 0;
    for (int i = pos - 1; i >= 0; i = (i & (i + 1)) - 1) {
      res += data[i];
      res %= MOD;
    }
    return res;
  }
  T sum(int l, int r) const {
    assert(0 <= l);
    assert(l <= r);
    assert(r <= n);
    return (sum(r) + (-sum(l))) % MOD;
  }
  using value_type = T;
  using update_type = T;
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<FenwickTree<ll>> dp(N + 1, FenwickTree<ll>(K + 10));
  dp[0].add(0, 1);
  for (int i = 1; i <= N; i++) {
    int a;
    cin >> a;
    for (int j = 0; j <= K; j++) {
      int mi = max(0, j - a);
      dp[i].add(j, dp[i - 1].sum(mi, j + 1));
    }
  }
  cout << dp[N].sum(K, K + 1) << endl;
}
