#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
class ST {
 public:
  vector<long long> st;
  vector<long long> lazy;
  int n;
  int left(int p) { return (p << 1); }
  int right(int p) { return (p << 1) + 1; }
  ST(int n) {
    this->n = n;
    st.assign(4 * n, 0);
    lazy.assign(4 * n, 0);
  }
  void update(int p, int L, int R, int UL, int UR, int val) {
    if (L > UR || R < UL) return;
    if (lazy[p]) {
      st[p] += ((R - L + 1) * lazy[p]) % mod;
      st[p] %= mod;
      if (L != R) {
        lazy[left(p)] += lazy[p];
        lazy[right(p)] += lazy[p];
      }
      lazy[p] = 0;
    }
    if (L == R) {
      st[p] += val;
      return;
    }
    if (L >= UL && R <= UR) {
      st[p] += ((R - L + 1) * val) % mod;
      st[p] %= mod;
      if (L != R) {
        lazy[left(p)] += val;
        lazy[right(p)] += val;
      }
      return;
    }
    update(left(p), L, (L + R) / 2, UL, UR, val);
    update(right(p), (L + R) / 2 + 1, R, UL, UR, val);
    st[p] = st[left(p)] + st[right(p)];
  }
  long long rsq(int p, int L, int R, int idx) {
    if (L > idx || R < idx) return 0;
    if (lazy[p]) {
      st[p] += ((R - L + 1) * lazy[p]) % mod;
      st[p] %= mod;
      if (L != R) {
        lazy[left(p)] += lazy[p];
        lazy[right(p)] += lazy[p];
      }
      lazy[p] = 0;
    }
    if (L == R) {
      return st[p];
    }
    return rsq(left(p), L, (L + R) / 2, idx) +
           rsq(right(p), (L + R) / 2 + 1, R, idx);
  }
};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> dp(k + 1);
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[0] = 1;
  ST dpst(k + 5);
  dpst.update(1, 0, k, 0, 0, 1);
  for (int i = 0; i < n; i++) {
    for (int j = k - 1; j >= 0; j--) {
      int val = dpst.rsq(1, 0, k, j);
      int l = j + 1;
      int r = j + a[i];
      if (l <= r) dpst.update(1, 0, k, l, r, val);
    }
  }
  cout << dpst.rsq(1, 0, k, k) << endl;
  return 0;
}
