#include <bits/stdc++.h>
using namespace std;
const long long M = 1006;
long long f[M], inv[M];
long long expo(long long base, long long exponent, long long mod) {
  long long ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}
void compute() {
  f[0] = 1;
  for (long long i = 1; i < M; i++) {
    f[i] = (1LL * i * f[i - 1]) % 998244353;
  }
  inv[M - 1] = expo(f[M - 1], 998244353 - 2, 998244353);
  for (long long i = M - 2; i >= 0; i--) {
    inv[i] = (1LL * (i + 1) * inv[i + 1]) % 998244353;
  }
}
long long C(long long n, long long r) {
  if (n < 0 || r < 0 || n < r) return 0;
  return (1LL * ((1LL * f[n] * inv[r]) % 998244353) * inv[n - r]) % 998244353;
}
long long n, dp[1005], ans, a[1005];
void solve() {
  compute();
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[n] = 1;
  for (long long i = n - 1; i >= 0; i--) {
    if (a[i] > 0 and a[i] < n - i) {
      for (long long j = i + 1; j < n + 1; j++) {
        dp[i] = (dp[i] + C(j - i - 1, a[i]) * dp[j]) % 998244353;
      }
    }
    ans += dp[i];
    ans %= 998244353;
  }
  cout << ans << '\n';
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
