#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++) {
      if (j == 0) {
        mat[i][j] = make_pair(1, 1);
      } else {
        mat[i][j] = make_pair(0, 1);
      }
    }
  }
  for (long long j = 1; j < k + 1; j++) {
    for (long long i = 1; i < n + 1; i++) {
      long long x = 0;
      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;
}
