#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const int MOD = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  vector<ll> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  vector<vector<ll>> dp(N + 1, vector<ll>(K + 1, 0));
  dp.at(0).at(0) = 1;
  for (int i = 0; i < N; i++) {
    ll sum = 0;
    for (int j = 0; j < K + 1; j++) {
      sum += dp.at(i).at(j);
      if (j - a.at(i) > 0) sum -= dp.at(i).at(j - a.at(i) - 1);
      sum %= MOD;
      dp.at(i + 1).at(j) += sum;
      dp.at(i + 1).at(j) %= MOD;
    }
  }
  cout << dp.at(N).at(K) << endl;
  return 0;
}
