#include <bits/stdc++.h>
using namespace std;
const int maxp = 22;
const long double EPS = 1e-18;
const long long INF = 2e18;
const int MOD = 998244353;
const int N = 5000;
long long power(long long x, long long n, long long m) {
  if (n == 0) return 1;
  long long ans = power(x, n / 2, m);
  ans = (ans * ans) % m;
  if (n % 2) ans = (ans * x) % m;
  return ans;
}
long long fact[N], inv[N];
void prep() {
  int i;
  fact[0] = 1;
  inv[0] = power(1, MOD - 2, MOD);
  for (i = 1; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % MOD;
    inv[i] = power(fact[i], MOD - 2, MOD);
  }
}
long long nck(int n, int k) {
  if (n < k) return 0;
  long long res = (fact[n] * inv[k]) % MOD;
  return (res * inv[n - k]) % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  int i, arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  int j;
  long long ans = 0;
  prep();
  long long dp[n + 1];
  dp[n] = 0;
  for (i = n - 1; i >= 0; i--) {
    int x = arr[i];
    long long curr = 0;
    if (x > 0) {
      for (j = i + x; j < n; j++) {
        long long cnt = nck(j - i - 1, x - 1);
        assert(cnt >= 1);
        curr = (curr + ((cnt * (dp[j + 1] + 1)) % MOD)) % MOD;
        {}
      }
    }
    dp[i] = (curr + dp[i + 1]) % MOD;
    {}
    ans = (ans + curr) % MOD;
  }
  cout << ans << '\n';
}
