#include <bits/stdc++.h>
using namespace std;
vector<int> segment;
int n, k, a[100001];
int getsum(int index) {
  long long sum = 0;
  index = index + 1;
  while (index) {
    sum += segment[index];
    index -= index & (-index);
  }
  return sum % 1000000007;
}
void update(int index, int val) {
  index = index + 1;
  while (index <= k + 1) {
    long long b = segment[index] + val;
    b %= 1000000007;
    if (b < 0) {
      b += 1000000007;
    }
    segment[index] = b;
    index += index & (-index);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cout.tie(NULL);
  cin.tie(NULL);
  cin >> n >> k;
  segment.resize(k + 2, 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) {
      long long sum =
          getsum(j) - getsum(max(-1, j - a[i] - 1)) - getsum(j) + getsum(j - 1);
      sum %= 1000000007;
      if (sum < 0) {
        sum -= 1000000007;
      }
      update(j, sum);
    }
  }
  cout << getsum(k) - getsum(k - 1) << endl;
}
