#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a[i];
  vector<vector<long long> > v(N);
  for (int i = 0; i < N; i++) v[i].resize(K + 1, 0);
  for (int j = 0; j <= a[N - 1]; j++) v[N - 1][j] = 1;
  for (int i = 0; i < N - 1; i++) v[i][0] = 1;
  long long modulo = 1e9 + 7;
  for (int i = N - 2; i >= 0; i--) {
    for (int j = 1; j <= a[i]; j++) {
      v[i][j] = (v[i][j - 1] + v[i + 1][j]) % modulo;
    }
    for (int j = a[i] + 1; j <= K; j++) {
      v[i][j] = (v[i][j - 1] + v[i + 1][j] - v[i + 1][j - a[i] - 1]) % modulo;
    }
  }
  cout << v[0][K] << "\n";
  return 0;
}
