#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
  return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  return (b < a) ? (a = b, 1) : 0;
}
template <typename T = ll>
struct SegmentTreeLazy {
 private:
  int n;
  vector<T> node, lazy;
  vector<bool> lazyFlag;

 public:
  SegmentTreeLazy(int sz) {
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, 0);
    lazyFlag.resize(2 * n - 1, false);
  }
  SegmentTreeLazy(vector<T> v) {
    int sz = int(v.size());
    n = 1;
    while (n < sz) n *= 2;
    node.resize(2 * n - 1, 0);
    lazy.resize(2 * n - 1, 0);
    lazyFlag.resize(2 * n - 1, false);
    for (int i = 0; i < sz; i++) node[i + n - 1] = v[i];
    for (int i = n - 2; i >= 0; i--)
      node[i] = min(node[i * 2 + 1], node[i * 2 + 2]);
  }
  void lazyEvaluate(int k, int l, int r) {
    if (lazyFlag[k]) {
      node[k] += lazy[k];
      if (r - l > 1LL) {
        lazy[k * 2LL + 1LL] += lazy[k];
        lazy[k * 2LL + 2LL] += lazy[k];
        lazyFlag[k * 2LL + 1LL] = lazyFlag[k * 2LL + 2LL] = true;
      }
      lazyFlag[k] = false;
      lazy[k] = 0;
    }
  }
  void update(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    lazyEvaluate(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] = x;
      lazyFlag[k] = true;
      lazyEvaluate(k, l, r);
    } else {
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }
  void add(int a, int b, int x, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    lazyEvaluate(k, l, r);
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      lazy[k] += x;
      lazyFlag[k] = true;
      lazyEvaluate(k, l, r);
    } else {
      add(a, b, x, 2 * k + 1, l, (l + r) / 2);
      add(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = node[2 * k + 1] + node[2 * k + 2];
    }
  }
  T find(int a, int b, int k = 0, int l = 0, int r = -1) {
    if (r < 0) r = n;
    lazyEvaluate(k, l, r);
    if (b <= l || r <= a) return 0;
    if (a <= l && r <= b) return node[k];
    T vl = find(a, b, 2 * k + 1, l, (l + r) / 2);
    T vr = find(a, b, 2 * k + 2, (l + r) / 2, r);
    return vl + vr;
  }
};
struct mint {
  ll v;
  ll mod;
  mint() : v(0) {}
  mint(signed v, ll mod = MOD) : v(v), mod(mod) {}
  mint(ll t, ll mod = MOD) : mod(mod) {
    v = t % mod;
    if (v < 0) v += mod;
  }
  mint pow(ll k) {
    mint res(1), tmp(v);
    while (k) {
      if (k & 1) res *= tmp;
      tmp *= tmp;
      k >>= 1;
    }
    return res;
  }
  static mint add_identity() { return mint(0); }
  static mint mul_identity() { return mint(1); }
  mint inv() { return pow(mod - 2); }
  mint &operator+=(mint a) {
    v += a.v;
    if (v >= mod) v -= mod;
    return *this;
  }
  mint &operator-=(mint a) {
    v += mod - a.v;
    if (v >= mod) v -= mod;
    return *this;
  }
  mint &operator*=(mint a) {
    v = 1LL * v * a.v % mod;
    return *this;
  }
  mint &operator/=(mint a) { return (*this) *= a.inv(); }
  mint operator+(mint a) const { return mint(v) += a; };
  mint operator-(mint a) const { return mint(v) -= a; };
  mint operator*(mint a) const { return mint(v) *= a; };
  mint operator/(mint a) const { return mint(v) /= a; };
  mint operator-() const { return v ? mint(MOD - v) : mint(v); }
  bool operator==(const mint a) const { return v == a.v; }
  bool operator!=(const mint a) const { return v != a.v; }
  bool operator<(const mint a) const { return v < a.v; }
};
int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  SegmentTreeLazy<mint> dp(k + 1);
  dp.add(0, 1, 1);
  for (int i = 0; i < n; ++i) {
    for (int j = k; j >= 0; --j) {
      mint val = dp.find(j, j + 1);
      if (val.v != 0) {
        dp.add(j + 1, j + 1 + a[i], val.v);
      }
    }
  }
  cout << dp.find(k, k + 1).v << "\n";
  return 0;
}
