#include <bits/stdc++.h>
using namespace std;
long long n, k, fw[100100];
const long long mod = 1e9 + 7;
void upd(long long p, long long v) {
  for (long long i = p; i <= k + 5; i += (i & (-i)))
    fw[i] += v % mod, fw[i] %= mod;
}
long long qry(long long p) {
  long long res = 0;
  for (long long i = p; i > 0; i -= (i & (-i))) res += fw[i] % mod, res %= mod;
  return res % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  long long sumai = 0;
  vector<long long> a(n);
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
    sumai += a[i];
  }
  long long cursum = 0;
  upd(1, 1);
  upd(2, -1);
  for (long long i = 0; i < n; i++) {
    for (long long j = k; j >= 0; j--) {
      long long qq = qry(j + 1) % mod;
      long long L = j + 1 + 1, R = min(a[i], k - j) + j + 1;
      if (R >= L) {
        upd(L, qq);
        upd(min(R + 1, k + 2), -qq);
      }
    }
  }
  cout << qry(k + 1) % mod;
}
