#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n, k;
  cin >> n >> k;
  long long a[n];
  for (long long i1 = 0; i1 < n; i1++) {
    cin >> a[i1];
  }
  pair<long long, long long> mat[n + 1][k + 1];
  for (long long i = 0; i < n + 1; i++) {
    for (long long j = 0; j < k + 1; j++) {
      mat[i][j] = make_pair(1, 1);
    }
  }
  for (long long j = 1; j < k + 1; j++) {
    for (long long i = 1; i < n + 1; i++) {
      long long x = 0;
      if (j == 1) {
        if (i == 1 && a[0] > 0) {
          x = 1;
        } else if (i > 1 && a[i - 1] > 0) {
          x = mat[i - 1][j].first + 1;
        } else if (i > 1 && a[i - 1] == 0) {
          x = mat[i - 1][j].first;
        }
      } else {
        long long start = j - a[i - 1];
        if (start < 0) {
          start = 0;
        }
        if (start == 0) {
          x = mat[i - 1][j].second;
        } else {
          x = mat[i - 1][j].second - mat[i - 1][start - 1].second;
        }
      }
      mat[i][j] =
          make_pair(x % 1000000007, (mat[i][j - 1].second + x) % 1000000007);
    }
  }
  cout << mat[n][k].first;
}
