#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 + 1, 0);
    int sum = 0;
    for (int j = 0; j <= k; j++) {
      sum += f[j];
      if (sum >= mod) sum -= mod;
      if (j > x) {
        sum += mod - f[j - x - 1];
        if (sum >= mod) sum -= mod;
      }
      nf[j] = sum;
    }
    f = nf;
  }
  cout << f[k] << endl;
  return 0;
}
