#include <bits/stdc++.h>
using namespace std;
const int N = (int)1e3 + 7;
int mod = 998244353;
int add(int a, int b) { return (a + b) % mod; }
int mult(long long a, long long b) { return (a * b) % mod; }
long long binpow(int a, int n) {
  long long res = 1;
  while (n) {
    if (n & 1) {
      res = mult(res, a);
    }
    a = mult(a, a);
    n >>= 1;
  }
  return res;
}
int a[N];
int dp[N];
int fact[N];
void precalc() {
  fact[0] = 1;
  for (int i = 1; i < N; i++) {
    fact[i] = mult(fact[i - 1], i);
  }
}
int cnk(int n, int k) {
  if (n < k) return 0;
  return mult(fact[n],
              mult(binpow(fact[k], mod - 2), binpow(fact[n - k], mod - 2)));
}
int main() {
  precalc();
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = n; i >= 1; i--) {
    if (i + a[i] <= n && a[i] > 0) {
      dp[i] = cnk(n - i, a[i]);
      for (int j = i + a[i]; j <= n; j++) {
        dp[i] = add(dp[i], mult(dp[j], cnk(j - i - 1, a[i])));
      }
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = add(ans, dp[i]);
  }
  cout << ans;
}
