#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> f(k + 1, 0);
  const int mod = 1000000007;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    vector<int> nf(k + 2, 0);
    for (int j = k; j >= 0; j--) {
      (nf[j] += f[j]) %= mod;
      (nf[min(k + 1, j + x + 1)] += mod - f[j]) %= mod;
    }
    for (int j = 1; j <= k; k++) (nf[j] += nf[j - 1]) %= mod;
    nf.resize(k + 1);
    f = nf;
  }
  cout << f[k] << endl;
  return 0;
}
