#include <bits/stdc++.h>
using namespace std;
const long long dx[] = {0, 1, 0, -1};
const long long dy[] = {1, 0, -1, 0};
const long long inf = 0x3f3f3f3f3f3f3f;
const long long mod = 998244353;
const long long N = 5e3 + 11;
long long n, fact[N], a[N], dp[N];
long long poww(long long n, long long p) {
  long long ans = 1;
  while (p) {
    if (p % 2) ans = (ans * n) % mod;
    n = (n * n) % mod;
    p /= 2;
  }
  return (ans + mod) % mod;
}
long long c(long long n, long long k) {
  long long ans = fact[n];
  long long x = poww(fact[k], mod - 2);
  x %= mod;
  long long y = poww(fact[n - k], mod - 2);
  y %= mod;
  ans = (ans * x) % mod;
  ans = (ans * y) % mod;
  return (ans + mod) % mod;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cerr.tie(0);
  cout.tie(0);
  cin >> n;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
  }
  fact[0] = 1;
  for (long long i = 1; i <= 2 * n; i++) {
    fact[i] = (i * fact[i - 1]) % mod;
  }
  long long anss = 0;
  dp[n + 1] = 1;
  for (long long i = n; i >= 1; i--) {
    if (a[i] <= 0) continue;
    for (long long j = i + a[i] + 1; j <= n + 1; j++) {
      dp[i] += (dp[j] * c(j - i - 1, a[i]));
      dp[i] %= mod;
    }
    anss = (anss + dp[i] + mod) % mod;
  }
  return cout << anss, 0;
}
