#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
ll mod(ll A, ll M) { return (A % M + M) % M; }
const ll INF = 1LL << 60;
template <class T>
bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll divceil(ll A, ll B) { return (A + (B - 1)) / B; }
ll myctoi(char C) { return C - '0'; }
char myitoc(ll N) { return '0' + N; }
int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<vector<ll>> dp(N + 10, vector<ll>(K + 10, 0));
  dp.at(0).at(0) = 1, dp.at(0).at(1) = -1;
  for (ll i = 0; i <= N; i++) {
    for (ll j = 0; j <= K; j++) {
      if (i != N) {
        dp.at(i + 1).at(j) += dp.at(i).at(j);
        dp.at(i + 1).at(j) %= MOD;
        if (j + A.at(i) + 1 <= K) {
          dp.at(i + 1).at(j + A.at(i) + 1) -= dp.at(i).at(j);
          dp.at(i + 1).at(j + A.at(i) + 1) %= MOD;
        }
      }
      if (j != K) {
        dp.at(i).at(j + 1) += dp.at(i).at(j);
        dp.at(i).at(j + 1) %= MOD;
      }
    }
  }
  ll ans = dp.at(N).at(K);
  cout << ans << endl;
}
