#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> data(n + 1);
  vector<long long> last(k + 1, 1);
  vector<long long> current(k + 1);
  for (int i = 0; i < n; ++i) cin >> data[i];
  int top, j;
  for (int i = n - 1; i >= 0; i--) {
    top = min(data[i], k);
    current[0] = last[0];
    for (j = 1; j <= top; ++j)
      current[j] = (current[j - 1] + last[j]) % 1000000007;
    for (; j <= k; ++j)
      current[j] =
          (current[j - 1] + last[j] - last[j - data[i] - 1]) % 1000000007;
    swap(current, last);
  }
  long long ans = last[k];
  if (k != 0) ans -= last[k - 1];
  cout << ans << "\n";
  return 0;
}
