#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline void read(T &x) {
  x = 0;
  bool f = false;
  char ch = getchar();
  while (!isdigit(ch)) {
    f |= ch == '-', ch = getchar();
  }
  while (isdigit(ch)) {
    x = (x << 1) + (x << 3) + (ch ^ 48);
    ch = getchar();
  }
  x = f ? -x : x;
  return;
}
template <typename T>
inline void write(T x) {
  if (x < 0) x = -x, putchar('-');
  if (x > 9) write(x / 10);
  putchar(x % 10 ^ 48);
  return;
}
const int N = 1e3 + 5, MOD = 998244353;
int n, m, val[N], dp[N], Ans, C[N][N];
int main() {
  read(n);
  for (int i = 1; i <= n; i++) read(val[i]), C[i][i] = C[i][0] = 1;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j < i; j++)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j] > +MOD
                     ? C[i - 1][j - 1] + C[i - 1][j] - MOD
                     : C[i - 1][j - 1] + C[i - 1][j]);
  dp[n + 1] = 1;
  for (int i = n; i >= 1; i--) {
    if (val[i] <= 0) continue;
    for (int j = val[i] + i + 1; j <= n + 1; j++)
      dp[i] = (dp[i] + 1ll * dp[j] * C[j - i - 1][val[i]] % MOD > +MOD
                   ? dp[i] + 1ll * dp[j] * C[j - i - 1][val[i]] % MOD - MOD
                   : dp[i] + 1ll * dp[j] * C[j - i - 1][val[i]] % MOD);
  }
  for (int i = 1; i <= n; i++)
    Ans = (Ans + dp[i] > +MOD ? Ans + dp[i] - MOD : Ans + dp[i]);
  write(Ans);
  return 0;
}
