#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 7;
const int lim = 2e3;
const int MOD = 998244353;
long long fac[N], inv[N];
void init() {
  fac[0] = inv[0] = inv[1] = 1;
  for (long long i = 1; i <= lim; i++) fac[i] = fac[i - 1] * i % MOD;
  for (long long i = 2; i <= lim; i++)
    inv[i] = (MOD - MOD / i) * inv[MOD % i] % MOD;
  for (long long i = 1; i <= lim; i++) inv[i] = inv[i - 1] * inv[i] % MOD;
}
long long C(long long n, long long m) {
  if (m > n) return 0;
  return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
int n, a[N];
long long dp[N];
int main() {
  init();
  scanf("%d", &n);
  dp[n + 1] = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = n; i >= 1; i--) {
    if (a[i] < 1 || a[i] > n - i) continue;
    for (int j = a[i] + i + 1; j <= n + 1; j++)
      dp[i] = (dp[i] + dp[j] * C(j - i - 1, a[i])) % MOD;
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) ans = (ans + dp[i]) % MOD;
  printf("%lld\n", ans);
  return 0;
}
