#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int main() {
  long long n, k;
  cin >> n >> k;
  vector<int> a(n + 1, 0);
  for (int i = 1; i <= n; i++) cin >> a[i];
  vector<vector<long long>> state(k + 1, vector<long long>(n + 1, 0));
  state[0][0] = 1;
  for (int i = 0; i <= k; i++)
    for (int j = 0; j <= n; j++) {
      if (i == j && j == 0) continue;
      state[i][j] =
          ((j - 1 < 0 ? 0
                      : (state[i][j - 1] -
                         (i - a[j] - 1 < 0 ? 0 : state[i - a[j] - 1][j - 1]))) +
           (i - 1 < 0 ? 0 : state[i - 1][j])) %
          MOD;
    }
  cout << (state[k][n] - (k - 1 < 0 ? 0 : state[k - 1][n])) % MOD << endl;
}
