#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1011;
const int Mod = 998244353;
long long f[Maxn], sum[Maxn];
int n, a[Maxn], c[Maxn][Maxn];
void init() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  c[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i][0] = 1;
    c[i][1] = i;
  }
  for (int i = 2; i <= n; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % Mod;
    }
  }
}
int main() {
  init();
  f[n] = 0;
  sum[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] <= 0 || a[i] > n) {
      sum[i] = sum[i + 1];
      continue;
    }
    for (int j = n; j > i; j--) {
      f[i] = ((f[i] + (sum[j + 1] + 1) * c[j - 1 - i][a[i] - 1]) % Mod) % Mod;
    }
    sum[i] = (sum[i + 1] + f[i]) % Mod;
  }
  cout << sum[1];
}
