#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ;
  long long int n, k;
  cin >> n >> k;
  if (n == 0) {
    cout << "0\n";
    return 0;
  }
  if (k == 0) {
    cout << "1\n";
    return 0;
  }
  vector<long long int> v(n);
  for (long long int i = 0; i < n; i++) {
    cin >> v[i];
  }
  vector<vector<long long int>> cummSum(n, vector<long long int>(k + 1, 0));
  long long int help;
  for (long long int i = 0; i <= k; i++) {
    help = 0;
    if (i <= v[0]) {
      help = 1;
    }
    if (i != 0)
      cummSum[0][i] = help + cummSum[0][i - 1];
    else
      cummSum[0][i] = help;
    cummSum[0][i] = (cummSum[0][i] % 1000000007);
  }
  for (long long int i = 1; i < n; i++) {
    for (long long int j = 0; j <= k; j++) {
      long long int left = j - v[i];
      if (left < 0) {
        left = 0;
      }
      if (left == 0) {
        cummSum[i][j] = cummSum[i - 1][j];
      } else {
        cummSum[i][j] = cummSum[i - 1][j] - cummSum[i - 1][left - 1];
      }
      cummSum[i][j] = (cummSum[i][j] % 1000000007);
      if (j != 0) {
        cummSum[i][j] += cummSum[i][j - 1];
        cummSum[i][j] = (cummSum[i][j] % 1000000007);
      }
    }
  }
  long long int ans;
  if (k != 0)
    ans = cummSum[n - 1][k] - cummSum[n - 1][k - 1];
  else
    ans = cummSum[n - 1][k];
  ans = (ans % 1000000007);
  cout << ans << "\n";
  return 0;
}
