#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())

#define REP(a, b) for (int a = 0; a < (b); a++)
#define FOR(a, b, c) for (int a = (b); a <= (c); a++)
#define REPD(a, b) for (int a = (b) - 1; a >= 0; a--)
#define FORD(a, b, c) for (int a = (b); a >= (c); a--)

#define MIN(a, b) (a) = min((a), (b))
#define MAX(a, b) (a) = max((a), (b))

#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2> &p) {
  return is >> p.fi >> p.se;
}

// {{{ ModInt<MOD>
// ax + by = gcd(a, b)
template <typename T>
T ext_gcd(T a, T b, T &x, T &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  T xx, yy, g = ext_gcd(b, a % b, xx, yy);
  x = yy;
  y = xx - yy * (a / b);
  return g;
}

template<int MOD>
struct ModInt {
 public:
  using sum_type = int;
  using prod_type = long long;

  static_assert(MOD > 0, "MOD should be positive");
  static_assert(MOD <= numeric_limits<sum_type>::max() - MOD, "Plus should not overflow");
  static_assert(MOD <= numeric_limits<prod_type>::max() / MOD, "Multiply should not overflow");

  struct good_val {};

  ModInt() : val_(0) {}

  ModInt(int val) : val_(val % MOD) { fix(op_neg{}); }

  ModInt(ll val) : val_(val % MOD) { fix(op_neg{}); }

  ModInt(int val, good_val) : val_(val) {
#ifdef __DEBUG
    assert(val_ >= 0 && val_ < MOD);
#endif
  }

  ModInt& operator+=(const ModInt &o) { val_ += o.val_; fix(op_pos{}); return *this; }
  ModInt& operator-=(const ModInt &o) { val_ -= o.val_; fix(op_neg{}); return *this; }
  ModInt& operator*=(const ModInt &o) { val_ = static_cast<prod_type>(1) * val_ * o.val_ % MOD; return *this; }
  ModInt& operator/=(const ModInt &o) { return operator*=(o.inverse()); }

  friend ModInt operator+(ModInt a, const ModInt &b) { a += b; return a; }
  friend ModInt operator-(ModInt a, const ModInt &b) { a -= b; return a; }
  friend ModInt operator*(ModInt a, const ModInt &b) { a *= b; return a; }
  friend ModInt operator/(ModInt a, const ModInt &b) { a /= b; return a; }

  ModInt inverse() const {
    prod_type a, b, g = ext_gcd<prod_type>(val_, MOD, a, b);
    if (g != 1) {
      throw;
    }
    debug assert(((*this) * a).val_ == 1);
    return ModInt(a);
  }

  sum_type get() const { return val_; }

 private:
  sum_type val_;
  struct op_neg {};
  struct op_pos {};

  void fix(op_neg) { if (val_ < 0) val_ += MOD; }
  void fix(op_pos) { if (val_ >= MOD) val_ -= MOD; }
};
// }}}

const int MOD = 1e9 + 7;

using MInt = ModInt<MOD>;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vi a(n);
  REP(i, n) cin >> a[i];
  VV<MInt> dp(n + 1, V<MInt>(k + 1, 0));
  dp[0][0] = 1;
  if (k > 0) dp[0][1] = -1;
  REP(i, n) {
    FOR(j, 1, k) dp[i][j] += dp[i][j - 1];
    FOR(j, 0, k) if (dp[i][j].get() > 0) {
      dp[i + 1][j] += dp[i][j];
      if (j + a[i] + 1 <= k) dp[i + 1][j + a[i] + 1] -= dp[i][j];
    }
  }
  FOR(i, 1, k) dp[n][i] += dp[n][i - 1];
  cout << dp[n][k].get() << endl;
}


Measured memory_bytes: 40192