#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const int N = 1e3 + 5;
long long fac[N], ifac[N];
long long be(long long b, long long e, long long m) {
  long long r = 1;
  while (e)
    if (e & 1)
      r = (r * b) % m, e ^= 1;
    else
      b = (b * b) % m, e >>= 1;
  return r;
}
long long cmb(int n, int k) {
  long long r = (fac[n] * ifac[k]) % MOD;
  return (r * ifac[n - k]) % MOD;
}
int n, A[N];
long long dp[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  fac[0] = ifac[0] = 1;
  for (long long x = 1; x < N; x++)
    fac[x] = (fac[x - 1] * (1LL * x)) % MOD, ifac[x] = be(fac[x], MOD - 2, MOD);
  cin >> n;
  for (int x = 0, qwerty = n; x < qwerty; x++) cin >> A[x];
  dp[n] = 1;
  for (int x = n - 1; x >= 0; x--) {
    if (A[x] <= 0 || x + A[x] >= n) continue;
    for (int y = x + A[x] + 1; y <= n; y++)
      dp[x] = (dp[x] + cmb(y - (x + 1), A[x]) * dp[y]) % MOD;
  }
  long long ans = 0;
  for (int x = 0; x < n; x++) {
    ans += dp[x];
    if (ans >= MOD) ans -= MOD;
  }
  cout << ans << "\n";
}
