#include <bits/stdc++.h>
using namespace std;
long long fact[1010];
long long ifact[1010];
long long pow_mod(long long x, long long y) {
  long long r = 1;
  for (; y; y >>= 1, x = (long long)x * x % 998244353)
    if (y & 1) r = (long long)r * x % 998244353;
  return r;
}
long long ncr(long long x, long long y) {
  if (y > x) return 0;
  long long ans = fact[x];
  ans = (ans * ifact[y]) % 998244353;
  ans = (ans * ifact[x - y]) % 998244353;
  return ans;
}
void pre() {
  fact[0] = 1;
  ifact[0] = 1;
  for (long long i = 1; i < 1010; i++) fact[i] = (fact[i - 1] * i) % 998244353;
  ifact[1010 - 1] = pow_mod(fact[1010 - 1], 998244353 - 2);
  for (long long i = 1010 - 2; i > 0; i--)
    ifact[i] = (ifact[i + 1] * (i + 1)) % 998244353;
}
int main() {
  int n;
  cin >> n;
  long long a[n + 10], dp[n + 10];
  for (int i = 0; i < n; i++) cin >> a[i];
  pre();
  memset(dp, 0, sizeof(dp));
  dp[n] = 1;
  for (int i = n - 1; i >= 0; --i) {
    if (a[i] <= 0) {
      dp[i] = 0;
      continue;
    }
    for (int j = i + a[i] + 1; j <= n; j++) {
      dp[i] = (dp[i] + dp[j] * ncr(j - i - 1, a[i])) % 998244353;
    }
  }
  long long sum = 0;
  for (int i = 0; i < n; i++) sum = (sum + dp[i]) % 998244353;
  cout << sum;
}
