#include <bits/stdc++.h>
using namespace std;
const long long oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long N, K;
  long long mod = 1000000007;
  cin >> N >> K;
  vector<long long> a(N, 0);
  vector<vector<long long> > dp(N + 1, vector<long long>(3 * (K + 1), 0));
  vector<long long> acc(N, 0);
  for (long long i = (0); i < (N); i++) cin >> a[i];
  dp[0][K] = 1;
  for (long long k = (K + 1) - 1; k >= (0); k--)
    for (long long c = (0); c < (N + 1); c++) {
      if (c > 0) {
        dp[c][k] = acc[c - 1];
      }
      if (c == N) continue;
      acc[c] = (acc[c] + dp[c][k]) % mod;
      acc[c] = (acc[c] - dp[c][k + a[c] + 1]) % mod;
    }
  cout << dp[N][0] << endl;
}
