#include <bits/stdc++.h>
using namespace std;
long long fact[200005];
long long power(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res *= a;
      res %= 998244353;
    }
    a *= a;
    a %= 998244353;
    b /= 2;
  }
  return res;
}
long long add(long long a, long long b) { return (0LL + a + b) % 998244353; }
long long sub(long long a, long long b) { return add(a, 998244353 - b); }
long long mul(long long a, long long b) { return (1LL * a * b) % 998244353; }
long long inv(long long x) { return power(x, 998244353 - 2); }
long long nCr(long long n, long long r) {
  return mul(fact[n], inv(mul(fact[r], fact[n - r])));
}
void solve() {
  long long n;
  cin >> n;
  long long arr[n];
  for (long long i = 0; i < n; i++) cin >> arr[i];
  long long dp[n];
  dp[n - 1] = 0;
  for (long long i = n - 2; i >= 0; i--) {
    dp[i] = dp[i + 1];
    if (arr[i] <= 0) continue;
    for (long long j = i + arr[i]; j < n; j++) {
      long long between = j - i;
      long long cur = 1;
      if (between > 1) cur = nCr(between - 1, arr[i] - 1);
      if (j + 1 < n && dp[j + 1] > 0) {
        cur = (cur * (dp[j + 1] + 1)) % 998244353;
      }
      dp[i] += cur;
      dp[i] %= 998244353;
    }
  }
  cout << dp[0] << "\n";
}
int32_t main() {
  fact[0] = 1;
  for (long long i = 1; i < 200005; i++) {
    fact[i] = mul(fact[i - 1], i);
  }
  long long t;
  t = 1;
  while (t--) {
    solve();
  }
}
