#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg_out() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg_out(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg_out(T...);
}
using vi = vector<long long>;
using pii = pair<long long, long long>;
using vp = vector<pii>;
using vv = vector<vector<long long>>;
const long long MOD = (long long)1e9 + 7;
const long long MOD2 = (long long)998244353;
const long long inf = (long long)1e18 + 1;
long long powb(long long a, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a;
    a = a * a;
    n >>= 1;
  }
  return res;
}
long long powb(long long a, long long n, long long m) {
  a %= m;
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = (res * a) % m;
    a = (a * a) % m;
    n >>= 1;
  }
  return res;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  vi ar(n + 1);
  for (long long i = n; i >= 1; i--) {
    cin >> ar[i];
  };
  vector<long long> fact(n + 1), inv(n + 1), dp(n + 1);
  fact[0] = 1;
  inv[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % MOD2;
    inv[i] = (inv[i - 1] * powb(i, MOD2 - 2, MOD2)) % MOD2;
  };
  auto nCr = [&](long long n, long long r) -> long long {
    if (n < r) return 0;
    return (fact[n] * ((inv[n - r] * inv[r]) % MOD2)) % MOD2;
  };
  dp[0] = 1;
  long long ans = 0;
  for (long long i = 2; i <= n; i++) {
    long long cur = ar[i] + 1;
    if (ar[i] <= 0) continue;
    for (long long prev_end = i - cur; prev_end >= 0; prev_end--) {
      dp[i] += (dp[prev_end] * nCr(i - prev_end - 1, ar[i])) % MOD2;
      dp[i] %= MOD2;
    }
    ans += dp[i];
    ans %= MOD2;
  }
  cout << ans << "\n";
  ;
  return 0;
}
