#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
constexpr ll INF = 1000000000;
namespace utils {
class Repeater {
  int st;
  int ed;
  int d;

 public:
  class rep_iterator {
    int i;
    int d;

   public:
    rep_iterator(int x, int pd) : i(x), d(pd) {}
    int &operator*() { return i; }
    bool operator==(const rep_iterator &k) const { return i == k.i; }
    bool operator!=(const rep_iterator &k) const { return i != k.i; }
    rep_iterator &operator++() {
      i += d;
      return *this;
    }
  };
  explicit Repeater(int N) : st(0), ed(N), d(1) {}
  Repeater(int b, int e) : st(b), ed(e), d(1) {
    if (st > ed) {
      st--;
      ed--;
      d = -1;
    }
  }
  rep_iterator begin() const { return rep_iterator(st, d); }
  rep_iterator end() const { return rep_iterator(ed, d); }
};
template <class T, class Compare>
using p_queue = priority_queue<T, vector<T>, Compare>;
template <class T>
using min_queue = p_queue<T, greater<T>>;
template <class T>
using max_queue = p_queue<T, less<T>>;
template <class T>
bool min_update(T &X, const T &A) {
  if (X > A) {
    X = A;
    return true;
  }
  return false;
}
template <class T>
bool max_update(T &X, const T &A) {
  if (X < A) {
    X = A;
    return true;
  }
  return false;
}
}  // namespace utils
using namespace utils;
namespace Xelmh_RCR {
class RCR {
 public:
  static const int64_t MOD = 1000000007;
  int64_t val;
  RCR(int64_t l) : val{l % MOD} {}
  RCR() : val{0} {}
  RCR pow(RCR m) const {
    RCR rv{1};
    auto nmul = val;
    while (m.val > 0) {
      if ((m.val & 1) == 1) {
        rv.val *= nmul;
        rv.val %= MOD;
      }
      nmul *= nmul;
      nmul %= MOD;
      m.val /= 2;
    }
    return rv;
  }
  RCR inv() const { return this->pow(MOD - 2); }
  void operator+=(const RCR &a) {
    val += a.val;
    val %= MOD;
  }
  void operator-=(const RCR &a) {
    val -= a.val;
    val %= MOD;
  }
  void operator*=(const RCR &a) {
    val *= a.val;
    val %= MOD;
  }
  void operator/=(const RCR &a) {
    val *= a.inv().val;
    val %= MOD;
  }
};
RCR operator+(const RCR &a, const RCR &b) { return (a.val + b.val) % RCR::MOD; }
RCR operator-(const RCR &a, const RCR &b) {
  return (a.val - b.val + RCR::MOD) % RCR::MOD;
}
RCR operator*(const RCR &a, const RCR &b) { return (a.val * b.val) % RCR::MOD; }
RCR operator/(const RCR &a, const RCR &b) {
  return (a.val * b.inv().val) % RCR::MOD;
}
RCR operator^(const RCR &a, const RCR &b) { return a.pow(b); }
bool operator==(const RCR &a, const RCR &b) { return a.val == b.val; }
bool operator!=(const RCR &a, const RCR &b) { return a.val != b.val; }
std::ostream &operator<<(std::ostream &os, const RCR &m) { return os << m.val; }
std::istream &operator>>(std::istream &is, RCR &m) { return is >> m.val; }
RCR fact(ll N) {
  static vector<RCR> cal(1, RCR{1});
  if (cal.size() > N)
    return cal[N];
  else {
    RCR nm = fact(N - 1);
    assert(cal.size() == N);
    cal.push_back(nm * N);
    return cal[N];
  }
}
RCR choice(ll N, ll k) {
  RCR ans = fact(N) / (fact(k) * fact(N - k));
  return ans;
}
}  // namespace Xelmh_RCR
using namespace Xelmh_RCR;
void sub_main(istream &is) {
  ll N, K;
  is >> N >> K;
  if (!is) return;
  vector<RCR> dp(K + 1, 0);
  dp[0] = 1;
  vector<ll> A(N);
  for (auto &&a : A) {
    is >> a;
  }
  for (int i = 0; i < N; ++i) {
    auto ndp = dp;
    RCR sum = 0;
    int len = 0;
    int rp = 0;
    for (int j = 0; j < dp.size(); ++j) {
      if (len > A[i]) {
        sum -= dp[rp];
        len--;
        rp++;
      }
      ndp[j] += sum;
      sum += dp[j];
      len++;
    }
    dp = ndp;
  }
  cout << dp[K] << endl;
}
int main(int argc, char *argv[]) {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(16) << scientific;
  sub_main(cin);
  return 0;
}
