#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e15;
const long long MAX = 2e6 + 7;
const long long MOD = 998244353;
const long double PI = 3.141592653589793238463;
vector<string> vec_splitter(string s) {
  for (char& c : s) c = c == ',' ? ' ' : c;
  stringstream ss;
  ss << s;
  vector<string> res;
  for (string z; ss >> z; res.push_back(z))
    ;
  return res;
}
void debug_out(vector<string> args, long long idx) { cerr << "\n"; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, long long idx, Head H, Tail... T) {
  if (idx > 0) cerr << ", ";
  stringstream ss;
  ss << H;
  cerr << args[idx] << " = " << ss.str();
  debug_out(args, idx + 1, T...);
}
long long i, j, k, t, n, q, l, r, mid;
long long first[MAX], inF[MAX];
long long mul(long long a, long long b) {
  return ((a % MOD) * (b % MOD)) % MOD;
}
long long add(long long a, long long b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}
long long power(long long a, long long b) {
  long long res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    b = b / 2;
    a = mul(a, a);
  }
  return res;
}
long long sub(long long a, long long b) {
  return ((a % MOD) - (b % MOD) + MOD) % MOD;
}
long long divi(long long a, long long b) { return mul(a, power(b, MOD - 2)); }
void fac(long long n) {
  first[0] = 1;
  for (long long i = 1; i < n + 1; i++) first[i] = mul(first[i - 1], i);
}
void invf(long long n) {
  inF[0] = 1;
  for (long long i = 1; i < n + 1; i++)
    inF[i] = mul(inF[i - 1], power(i, MOD - 2));
}
void init() {
  first[0] = 1;
  for (long long i = 1; i < MAX; i++) first[i] = mul(i, first[i - 1]);
  inF[MAX - 1] = power(first[MAX - 1], MOD - 2);
  for (long long i = MAX - 1; i >= 1; i--) inF[i - 1] = mul(i, inF[i]);
}
long long ncr(long long n, long long r) {
  if (n < r || r < 0) return 0;
  return mul(first[n], mul(inF[r], inF[n - r]));
}
long long dpd[MAX], a[MAX];
long long gbg(long long pos) {
  if (pos == n) return 1;
  if (dpd[pos] != -1) return dpd[pos];
  long long val, cnt = 0;
  for (long long i = pos + a[pos] + 1; i < n + 1; i++) {
    if (a[i] > 0 || i == n)
      val = gbg(i);
    else
      val = 0;
    if (val > 0) cnt = add(cnt, mul(ncr(i - (pos + 1), a[pos]), (val)));
  }
  return dpd[pos] = cnt;
}
long long ans;
void solve() {
  init();
  memset(dpd, -1, sizeof(dpd));
  cin >> n;
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (long long i = 0; i < n; i++)
    if (a[i] > 0) {
      ans = add(ans, gbg(i));
    }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
  return 0;
}
