#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;
void add(vector<ll>& data, vector<ll>& datb, ll a, ll b, ll x, ll k, ll l,
         ll r) {
  if (a <= l && r <= b) {
    data[k] = (data[k] + x) % MOD;
  } else if (l < b && a < r) {
    datb[k] = (datb[k] + (min(b, r) - max(a, l)) * x) % MOD;
    add(data, datb, a, b, x, k * 2 + 1, l, (l + r) / 2);
    add(data, datb, a, b, x, k * 2 + 2, (l + r) / 2, r);
  }
}
ll sum(vector<ll>& data, vector<ll>& datb, ll a, ll b, ll k, ll l, ll r) {
  if (b <= l || r <= a) return 0;
  if (a <= l && r <= b) return data[k] * (r - l) + datb[k];
  ll res = (min(b, r) - max(a, l)) * data[k] % MOD;
  res = (res + sum(data, datb, a, b, k * 2 + 1, l, (l + r) / 2)) % MOD;
  res = (res + sum(data, datb, a, b, k * 2 + 2, (l + r) / 2, r)) % MOD;
}
int main() {
  constexpr int DATSIZE = (1 << 18) - 1;
  ll N, K;
  cin >> N >> K;
  vector<ll> a(N);
  vector<vector<ll>> data(N + 1, vector<ll>(DATSIZE, 0));
  vector<vector<ll>> datb(N + 1, vector<ll>(DATSIZE, 0));
  for (ll((i)) = (0); ((i)) < ((N)); ((i))++) cin >> a[i];
  add(data[0], datb[0], 0, 1, 1, 0, 0, K + 1);
  for (ll((i)) = (0); ((i)) < ((N)); ((i))++)
    for (ll((j)) = (0); ((j)) < ((K + 1)); ((j))++) {
      ll way = sum(data[i], datb[i], j, j + 1, 0, 0, K + 1);
      add(data[i + 1], datb[i + 1], j, j + a[i] + 1, way, 0, 0, K + 1);
    }
  cout << sum(data.back(), datb.back(), K, K + 1, 0, 0, K + 1) << endl;
  cin >> N;
  return 0;
}
