#include <bits/stdc++.h>
using namespace std;
const int m = 1e9 + 7;
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(0);
  int n, x, k;
  cin >> n >> k;
  vector<int> v(k + 1, 0);
  v[0] = 1;
  for (int i = 0; i < n; i++) {
    cin >> x;
    vector<int> tmp(k + 1, 0);
    for (int ses = k; ses >= 0; ses--) {
      int add = v[ses], l = ses + 1, r = ses + min(x, k - ses);
      r = min(r, k);
      if (l <= r) {
        r++;
        tmp[l] = (tmp[l] + add) % m;
        tmp[r] = (tmp[r] - add) % m;
        tmp[r] = (tmp[r] + m) % m;
      }
    }
    int sum = 0;
    for (int j = 0; j <= k; j++) {
      sum += tmp[j];
      sum %= m;
      sum += m;
      sum %= m;
      v[j] += sum;
      v[j] %= m;
      v[j] += m;
      v[j] %= m;
    }
  }
  cout << v[k] % m << "\n";
  return 0;
}
