#include <bits/stdc++.h>
using namespace std;
const long long N = 1e3 + 5;
const long long inf = -1e18;
const long long mod = 998244353;
long long fact[N], invfact[N];
long long dp[N], pref[N];
long long binpow(long long b, long long p) {
  long long res = 1;
  while (p) {
    if (p & 1) res = (res * b) % mod;
    b = (b * b) % mod;
    p /= 2;
  }
  return res;
}
void precalc() {
  fact[0] = 1;
  for (long long i = 1; i < N; i++) fact[i] = (fact[i - 1] * i) % mod;
  invfact[N - 1] = binpow(fact[N - 1], mod - 2);
  for (long long i = N - 2; i >= 0; i--)
    invfact[i] = (invfact[i + 1] * (i + 1)) % mod;
}
long long ncr(long long n, long long r) {
  long long res = (fact[n] * invfact[r]) % mod;
  res = (res * invfact[n - r]) % mod;
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  precalc();
  long long n;
  cin >> n;
  long long a[n + 1];
  for (long long i = 1; i <= n; i++) cin >> a[i];
  dp[n + 1] = 1ll;
  long long ans = 0;
  for (long long i = n; i >= 1; i--) {
    if (a[i] <= 0) continue;
    for (long long j = i + a[i] + 1; j < n + 2; j++) {
      long long val = (ncr(j - i - 1, a[i]) * dp[j]) % mod;
      dp[i] = (dp[i] + val) % mod;
    }
    ans = (ans + dp[i]) % mod;
  }
  cout << ans << endl;
  return 0;
}
