#include <bits/stdc++.h>
template <typename Y>
inline bool updmin(Y &a, Y b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename Y>
inline bool updmax(Y &a, Y b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename Y>
inline Y abs(Y a) {
  if (a < 0) a = -a;
  return a;
}
template <typename Y>
inline Y sqr(Y a) {
  return a * a;
}
int read() {
  int w = 1, q = 0, ch = ' ';
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') w = -1;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) q = q * 10 + ch - 48;
  return q * w;
}
inline void FileIO() {
  freopen(
      ""
      ".in",
      "r", stdin);
  freopen(
      ""
      ".out",
      "w", stdout);
}
const int N = 1020, mod = 998244353;
int n, a[N], fac[N], inv[N], f[N];
inline int C(int x, int y) {
  if (x < y || y < 0) return 0;
  return (long long)fac[x] * inv[y] % mod * inv[x - y] % mod;
}
int main() {
  n = read();
  for (int i = 1; i <= n; i++) {
    a[i] = read();
  }
  fac[0] = fac[1] = 1;
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; i++) {
    fac[i] = (long long)fac[i - 1] * i % mod;
    inv[i] = mod - (long long)mod / i * inv[mod % i] % mod;
  }
  for (int i = 2; i <= n; i++) {
    inv[i] = (long long)inv[i] * inv[i - 1] % mod;
  }
  for (int i = 1; i <= n; i++) {
    ++f[i] %= mod;
    if (a[i] <= 0) continue;
    for (int j = i + 1; j <= n + 1; j++) {
      f[j] = (f[j] + (long long)f[i] * C(j - i - 1, a[i])) % mod;
    }
  }
  printf("%d\n", f[n + 1]);
  return 0;
}
