#include <bits/stdc++.h>
using namespace std;
long long read() {
  long long x;
  scanf("%lld", &x);
  return x;
};
const long long N = 1050;
const long long MOD = (int)998244353;
long long F[N], Finv[N], inv[N];
void init() {
  inv[1] = 1;
  for (long long i = 2; i < N; i++) {
    inv[i] = (MOD - MOD / i) * 1ll * inv[MOD % i] % MOD;
  }
  F[0] = Finv[0] = 1;
  for (long long i = 1; i < N; i++) {
    F[i] = F[i - 1] * 1ll * i % MOD;
    Finv[i] = Finv[i - 1] * 1ll * inv[i] % MOD;
  }
}
long long C(long long n, long long m) {
  if (m < 0 || m > n) return 0;
  return F[n] * 1ll * Finv[n - m] % MOD * Finv[m] % MOD;
}
long long n;
long long a[1050];
long long dp1[1050][1050];
long long dp[1050];
int main() {
  init();
  n = read();
  for (long long i = 1; i <= n; ++i) a[i] = read();
  memset(dp1, 0, sizeof(dp1));
  for (long long l = 1; l <= n; ++l) {
    for (long long r = l + 1; r <= n; ++r) {
      long long num = a[l];
      if (num <= 0) continue;
      num--;
      dp1[l][r] += C((r - l - 1), num);
      dp1[l][r] %= MOD;
    }
  }
  memset(dp, 0, sizeof(dp));
  dp[0] = 1;
  for (long long i = 1; i <= n; i++) {
    long long sum = 0;
    for (long long j = i - 1; j >= 0; j--) {
      dp[i] += dp[j] * sum;
      dp[i] %= MOD;
      sum += dp1[j][i];
      sum %= MOD;
    }
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) {
    ans += dp[i];
    ans %= MOD;
  }
  cout << ans << endl;
}
