#include <bits/stdc++.h>
using namespace std;
const int maxN = 1e3 + 11, mol = 998244353;
int N, A[maxN];
long long F[maxN], P[maxN];
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long res = power(a, b / 2);
  res = res * res % mol;
  return b % 2 ? res * a % mol : res;
}
long long combine(int k, int n) {
  if (k > n) return 0;
  return P[n] * power(P[k], mol - 2) % mol * power(P[n - k], mol - 2) % mol;
}
int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> A[i];
  P[0] = P[1] = 1;
  for (int i = 2; i <= N; i++) P[i] = P[i - 1] * i % mol;
  F[0] = F[1] = 0;
  for (int i = 2; i <= N; i++) {
    F[i] = F[i - 1];
    for (int j = 1; j < i; j++)
      if (A[j] >= 1)
        F[i] = (F[i] + combine(A[j] - 1, i - j - 1) * (F[j - 1] + 1)) % mol;
  }
  cout << F[N];
}
