#include <bits/stdc++.h>
using namespace std;
const long long FACT_MAX = 3000;
const long long MOD = 998244353;
long long famod[FACT_MAX + 1];
long long simod[FACT_MAX + 1];
long long fimod[FACT_MAX + 1];
void create_fact_mod(int num) {
  famod[0] = 1;
  famod[1] = 1;
  long long i;
  for (i = 2; i <= num; i++) {
    famod[i] = famod[i - 1] * i % MOD;
  }
}
void create_seq_inv_mod(int num) {
  simod[0] = 1;
  simod[1] = 1;
  long long i;
  for (i = 2; i <= num; i++) {
    simod[i] = (MOD - MOD / i) * simod[MOD % i] % MOD;
  }
}
void create_fact_inv_mod(int num) {
  fimod[0] = 1;
  fimod[1] = 1;
  long long i;
  for (i = 2; i <= num; i++) {
    fimod[i] = fimod[i - 1] * simod[i] % MOD;
  }
}
void create_mod_tables(int num) {
  create_fact_mod(num);
  create_seq_inv_mod(num);
  create_fact_inv_mod(num);
}
long long comb_mod(int n, int k) {
  return famod[n] * fimod[n - k] % MOD * fimod[k] % MOD;
}
int main() {
  long long i, j, k;
  long long A[1000];
  int N;
  cin >> N;
  for (i = 0; i < N; i++) cin >> A[i];
  create_mod_tables(N);
  long long dp[1001];
  long long base = 1;
  for (i = 0; i <= N; i++) dp[i] = 0;
  for (i = 1; i <= N; i++) {
    base = (base + dp[i - 1]) % MOD;
    if (A[i - 1] <= 0 || A[i - 1] > N - i) continue;
    for (j = i + A[i - 1]; j <= N; j++) {
      long long c = comb_mod(j - i - 1, A[i - 1] - 1);
      dp[j] = (dp[j] + base * c % MOD) % MOD;
    }
  }
  long long ans = 0;
  for (i = 1; i <= N; i++) ans = (ans + dp[i]) % MOD;
  cout << ans << endl;
  return 0;
}
