#include <bits/stdc++.h>
using namespace std;
using lld = long double;
using ull = unsigned long int;
using ll = long long;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  const int precision = 13;
  cout.precision(precision);
  cout.setf(ios_base::fixed);
  const ll mod = 1e9 + 7;
  int n;
  ll k;
  cin >> n >> k;
  vector<ll> a(n);
  for (auto& it : a) cin >> it;
  vector<vector<ll>> dp(2, vector<ll>(k + 1));
  fill(dp[1].begin(), dp[1].end(), 1);
  for (int i = 0; i < n; ++i) {
    int cur = i & 1;
    int prev = cur ^ 1;
    for (ll c = 0; c <= k; ++c) {
      ll acc = dp[prev][c] - (a[i] < c ? dp[prev][c - a[i] - 1] : 0ll);
      dp[cur][c] = acc + (c > 0 ? dp[cur][c - 1] : 0ll) + mod;
      dp[cur][c] %= mod;
    }
  }
  int cur = (n - 1) & 1;
  ll ans = dp[cur][k] - (k > 0 ? dp[cur][k - 1] : 0);
  cout << ans << '\n';
  return 0;
}
