#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const long long EPS = 1e-9;
long long mpow(long long a, long long b, long long p = MOD) {
  a = a % p;
  long long res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a) % p;
    a = (a * a) % p;
    b = b >> 1;
  }
  return res % p;
}
const long long N = 1e6 + 5;
long long dp[N];
long long fac[N];
long long ncm(long long n, long long m) {
  if (m > n) return 0;
  long long ans = fac[n];
  ans = (ans * mpow(fac[m], MOD - 2)) % MOD;
  ans = (ans * mpow(fac[n - m], MOD - 2)) % MOD;
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  fac[0] = 1;
  for (long long i = 1; i < N; i++) {
    fac[i] = (i * fac[i - 1]) % MOD;
  }
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  dp[n] = 1;
  long long ans = 0;
  for (long long i = n - 1; i >= 0; i--) {
    dp[i] = dp[i + 1];
    if (a[i] <= 0) continue;
    for (long long j = i + 1; j < n; j++) {
      if (j - i < a[i]) continue;
      long long rem = a[i] - 1;
      long long oo = j - i - 1;
      long long c = ncm(oo, rem) * dp[j + 1];
      ans += c;
      ans %= MOD;
      dp[i] += c;
      dp[i] %= MOD;
    }
  }
  cout << ans;
}
