#include <bits/stdc++.h>
using namespace std;
template <class A>
void pr(A a) {
  cout << a;
  cout << '\n';
}
template <class A, class B>
void pr(A a, B b) {
  cout << a << ' ';
  pr(b);
}
template <class A, class B, class C>
void pr(A a, B b, C c) {
  cout << a << ' ';
  pr(b, c);
}
template <class A, class B, class C, class D>
void pr(A a, B b, C c, D d) {
  cout << a << ' ';
  pr(b, c, d);
}
template <class A>
void PR(A a, long long n) {
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    if (i) cout << ' ';
    cout << a[i];
  }
  cout << '\n';
}
long long check(long long n, long long m, long long x, long long y) {
  return x >= 0 && x < n && y >= 0 && y < m;
}
const long long MAX = 1e9 + 7, MAXL = 1LL << 61, dx[4] = {-1, 0, 1, 0},
                dy[4] = {0, 1, 0, -1};
int N = 1 << 18;
class StarrySkyTree {
 public:
  long long Mi[555555], A[555555];
  void init() { memset(Mi, 0, sizeof(Mi)), memset(A, 0, sizeof(A)); }
  void add(int a, int b, long long x, int k = 0, int l = 0, int r = N) {
    if (r <= a || b <= l) return;
    if (a <= l && r <= b) {
      A[k] += x;
      A[k] %= MAX;
      while (k) {
        k = (k - 1) / 2;
        Mi[k] = min(Mi[k * 2 + 1] + A[k * 2 + 1], Mi[k * 2 + 2] + A[k * 2 + 2]);
      }
      return;
    }
    add(a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(a, b, x, k * 2 + 2, (l + r) / 2, r);
  }
  long long getMin(int a, int b, int k = 0, int l = 0, int r = N) {
    if (r <= a || b <= l) return LLONG_MAX;
    if (a <= l && r <= b) return (Mi[k] + A[k]) % MAX;
    long long left = getMin(a, b, k * 2 + 1, l, (l + r) / 2),
              right = getMin(a, b, k * 2 + 2, (l + r) / 2, r);
    return (min(left, right) + A[k]) % MAX;
  }
};
StarrySkyTree t;
void Main() {
  long long n, m;
  cin >> n >> m;
  long long a[n];
  for (long long i = (long long)(0); i < (long long)(n); i++) cin >> a[i];
  t.init();
  t.add(0, 1, 1);
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    for (long long j = (long long)(m + 1) - 1; j >= 0; j--) {
      long long x = t.getMin(j, j + 1);
      t.add(j + 1, min(j + a[i] + 1, m + 1), x);
    }
  }
  pr(t.getMin(m, m + 1));
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  Main();
  return 0;
}
