/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-02-04 17:19:39
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...) 1728
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

constexpr int64 MOD = 1e9 + 7;

template <class Monoid, class Function>
class SegmentTree {
 public:
  SegmentTree(const std::vector<Monoid>& data, Monoid identity_element,
              Function function)
      : identity_element_(identity_element), data_(data), function_(function) {
    Build();
  }

  void Update(size_t position, Monoid new_value) {
    position += n_;
    node_[position] = new_value;
    while (position > 0) {
      position >>= 1;
      node_[position] = function_(node_[2 * position], node_[2 * position + 1]);
    }
  }

  // return Query[left, right)
  Monoid Query(int left, int right) {
    Monoid vl = identity_element_, vr = identity_element_;
    for (left += n_, right += n_; left < right; left >>= 1, right >>= 1) {
      if (left & 1) vl = function_(vl, node_[left++]);
      if (right & 1) vr = function_(node_[--right], vr);
    }
    return function_(vl, vr);
  }

  Monoid operator[](size_t position) const { return node_[n_ + position]; }

 private:
  size_t n_;
  Monoid identity_element_;
  std::vector<Monoid> data_;
  std::vector<Monoid> node_;
  Function function_;

  void Build() {
    size_t SIZE = data_.size();
    n_ = 1;
    while (n_ < SIZE) {
      n_ <<= 1;
    }
    node_.assign(2 * n_, identity_element_);
    for (size_t i = 0; i < SIZE; ++i) {
      node_[i + n_] = data_[i];
    }
    for (size_t i = n_ - 1; i > 0; --i) {
      node_[i] = function_(node_[2 * i], node_[2 * i + 1]);
    }
  }
};


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, k; cin >> n >> k;
  vector<int> a(n); cin >> a;

  // dp[i][j] : i 人目までで j 個使うときの場合の数
  vector<vector<int64>> dp(n + 1, vector<int64>(k + 1, 0LL));
  dp[0][0] = 1;

  auto f = [](int64 x, int64 y) { return (x + y) % MOD; };
  SegmentTree<int64, decltype(f)> seg(vector<int64>(101010, 0LL), 0LL, f);

  seg.Update(0, 1LL);

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= k; ++j) {
      dp[i + 1][j] += seg.Query(max(0, j - a[i]), j + 1);
      dp[i + 1][j] %= MOD;
    }
    for (int j = 0; j <= k; ++j) {
      seg.Update(j, dp[i + 1][j]);
    }
  }

  //debug(dp);

  cout << dp[n][k] << endl;

  return 0;
}

Measured memory_bytes: 84312