#include <bits/stdc++.h>
using namespace std;
static const int kModulo = 1000 * 1000 * 1000 + 7;
int main() {
  ios::sync_with_stdio(false);
  int N, K;
  cin >> N >> K;
  vector<int> ways(K + 1, 0);
  ways[0] = 1;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    vector<int> partial(N);
    for (int j = 0; j <= K; ++j) {
      partial[j] = ways[j];
      if (j > 0) partial[j] = (partial[j] + partial[j - 1]) % kModulo;
    }
    for (int j = 0; j <= K; ++j) {
      ways[j] = partial[j];
      if (j > a) ways[j] = (ways[j] + kModulo - partial[j - a - 1]) % kModulo;
    }
  }
  cout << ways[K] << "\n";
}
