#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
const ll MOD = (ll)1e9 + 7;
int main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  ll k;
  cin >> k;
  vl a(n);
  for (ll i = (0); i < (n); i++) cin >> a[i];
  vvl dp(n + 1, vl(k + 1, 0));
  dp[0][0] = 1;
  for (ll i = (1); i < (n + 1); i++) {
    ll len = 0;
    ll ges = 0;
    for (ll j = (0); j < (k + 1); j++) {
      ges = (ges + dp[i - 1][j]) % MOD;
      if (len == a[i - 1] + 1) {
        ges = (ges - dp[i - 1][j - a[i - 1] - 1]) % MOD;
      } else {
        len++;
      }
      dp[i][j] = ges;
    }
  }
  cout << dp[n][k] << endl;
  return 0;
}
