#include <bits/stdc++.h>
using namespace std;
int N, K;
const int MOD = 1000000007;
int main() {
  cin >> N >> K;
  vector<long long> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  vector<vector<long long> > dp(N, vector<long long>(K + 1, 0));
  if (K == 0) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 0; i < N; i++) {
    int ai = a.at(i);
    for (int j = 0; j < K + 1; j++) {
      long long &ndp = dp.at(i).at(j);
      if (i == 0) {
        ndp = min(j + 1, ai + 1);
        continue;
      }
      if (j != 0) ndp += dp.at(i).at(j - 1);
      ndp += dp.at(i - 1).at(j);
      if (j >= ai + 1) ndp -= dp.at(i - 1).at(j - ai - 1);
      (ndp += MOD) %= MOD;
    }
  }
  cout << dp.at(N - 1).at(K) - dp.at(N - 1).at(K - 1) << endl;
}
