#include <bits/stdc++.h>
using namespace std;
vector<long long> segment;
int n, k, t, a[100001];
long long getsum(int a, int b, int curr, int l, int r) {
  if (b < l || a > r) {
    return 0;
  }
  if (a <= l && b >= r) {
    return segment[curr];
  }
  int m = (l + r) / 2;
  return (getsum(a, b, 2 * curr, l, m) + getsum(a, b, 2 * curr + 1, m + 1, r)) %
         1000000007;
}
void update(int curr, long long val) {
  curr += t;
  segment[curr] = val;
  curr /= 2;
  while (curr) {
    segment[curr] = (segment[2 * curr] + segment[2 * curr + 1]) % 1000000007;
    curr /= 2;
  }
}
int main() {
  cin >> n >> k;
  t = pow(2, ceil(log2(k + 1)));
  segment.resize(2 * t, 0);
  for (int i = 0; i < n; i += 1) {
    cin >> a[i];
  }
  update(0, 1);
  for (int i = 0; i < n; i += 1) {
    for (int j = k; j > 0; j -= 1) {
      update(j, getsum(max(1, j - a[i] + 1), j + 1, 1, 1, t));
    }
  }
  cout << segment[k + t] << endl;
}
