#include <bits/stdc++.h>
using namespace std;
using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;
inline void yes() {
  cout << "Yes" << '\n';
  exit(0);
}
inline void no() {
  cout << "No" << '\n';
  exit(0);
}
inline i64 gcd(i64 a, i64 b) {
  if (min(a, b) == 0) return max(a, b);
  if (a % b == 0) return b;
  return gcd(b, a % b);
}
inline i64 lcm(i64 a, i64 b) {
  if (min(a, b) == 0) return max(a, b);
  return a / gcd(a, b) * b;
}
inline u64 xorshift() {
  static u64 x = 88172645463325252ull;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}
template <typename T>
class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T>
class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T>
inline void amax(T &x, T y) {
  if (x < y) x = y;
}
template <typename T>
inline void amin(T &x, T y) {
  if (x > y) x = y;
}
template <typename T>
inline T exp(T x, i64 n, T e = 1) {
  T r = e;
  while (n > 0) {
    if (n & 1) r *= x;
    x *= x;
    n >>= 1;
  }
  return r;
}
template <typename T>
inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) {
  while (abs(ok - ng) > eps) {
    T mi = (ok + ng) / 2;
    (f(mi) ? ok : ng) = mi;
  }
  return ok;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  for (int i = 0; i < int(v.size()); i++) {
    if (i) os << ' ';
    os << v[i];
  }
  return os;
}
void solve();
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(16);
  solve();
  return 0;
}
template <int mod>
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(long long a) {
    x = a % mod;
    if (x < 0) x += mod;
  }
  ModInt &operator+=(ModInt that) {
    x = (x + that.x) % mod;
    return *this;
  }
  ModInt &operator-=(ModInt that) {
    x = (x + mod - that.x) % mod;
    return *this;
  }
  ModInt &operator*=(ModInt that) {
    x = (long long)x * that.x % mod;
    return *this;
  }
  ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
  ModInt inverse() {
    int a = x, b = mod, u = 1, v = 0;
    while (b) {
      int t = a / b;
      a -= t * b;
      u -= t * v;
      swap(a, b);
      swap(u, v);
    }
    return ModInt(u);
  }
  ModInt operator+(ModInt that) { return ModInt(*this) += that; }
  ModInt operator-(ModInt that) { return ModInt(*this) -= that; }
  ModInt operator*(ModInt that) { return ModInt(*this) *= that; }
  ModInt operator/(ModInt that) { return ModInt(*this) /= that; }
  friend ostream &operator<<(ostream &os, ModInt m) { return os << m.x; }
};
using mint = ModInt<1000000007>;
struct LazySegmentTree {
  vector<mint> v;
  vector<mint> z;
  mint e;
  mint d;
  int n;
  inline mint f(mint a, mint b) { return a + b; }
  inline mint g(mint a, mint b, int k) { return a + b * k; }
  inline mint h(mint a, mint b) { return a + b; }
  LazySegmentTree(int size, mint e, mint d) : e(e), d(d) {
    n = 1;
    while (n < size) n <<= 1;
    v.resize(n * 2, e);
    z.resize(n * 2, d);
  }
  void set(int k, mint x) { v[k + n] = x; }
  void build() {
    for (int i = n - 1; i >= 0; i--) {
      v[i] = f(v[i * 2 + 0], v[i * 2 + 1]);
    }
  }
  void propagate(int k, int l, int r) {
    v[k] = g(v[k], z[k], r - l);
    if (k < n) {
      z[k * 2 + 0] = h(z[k * 2 + 0], z[k]);
      z[k * 2 + 1] = h(z[k * 2 + 1], z[k]);
    }
    z[k] = d;
  }
  mint update(int a, int b, mint x, int k = 1, int l = 0, int r = -1) {
    if (r == -1) r = n;
    propagate(k, l, r);
    if (b <= l || r <= a) return v[k];
    if (a <= l && r <= b) {
      z[k] = x;
      propagate(k, l, r);
      return v[k];
    }
    return v[k] = f(update(a, b, x, k * 2 + 0, l, (l + r) / 2),
                    update(a, b, x, k * 2 + 1, (l + r) / 2, r));
  }
  mint query(int a, int b, int k = 1, int l = 0, int r = -1) {
    if (r == -1) r = n;
    propagate(k, l, r);
    if (b <= l || r <= a) return e;
    if (a <= l && r <= b) return v[k];
    return f(query(a, b, k * 2 + 0, l, (l + r) / 2),
             query(a, b, k * 2 + 1, (l + r) / 2, r));
  }
  mint operator[](int i) { return query(i, i + 1); }
};
void solve() {
  int n, k;
  cin >> n >> k;
  vi32 a(n);
  cin >> a;
  vector<LazySegmentTree> dp;
  for (int i = 0; i <= int(n); i++) {
    dp.push_back(LazySegmentTree(k + 1, 0, 0));
  }
  dp[0].set(0, 1);
  dp[0].build();
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j <= int(k); j++) {
      dp[i + 1].update(j, min(j + a[i] + 1, k + 1), dp[i][j]);
    }
  cout << dp[n][k] << endl;
}
