#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  vector<int> rest(N);
  rest[N - 1] = 0;
  for (int i = N - 2; i >= 0; i--) {
    rest[i] = rest[i + 1] + a[i + 1];
  }
  vector<int> before(K + 2, 1);
  vector<int> next(K + 2);
  before[0] = 0;
  next[0] = 0;
  for (int i = 0; i < N; i++) {
    int temp = a[i];
    int lower = max(0, K - rest[i]);
    for (int j = 0; j < lower; j++) {
      next[j + 1] = 0;
    }
    for (int j = lower; j <= K; j++) {
      next[j + 1] =
          (next[j] + (before[j + 1] - before[max(0, j - temp)])) % MOD;
    }
    swap(before, next);
  }
  cout << before[K + 1] << endl;
  return 0;
}
