#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 998244353;
int N;
int a[1000];
lint dp[1000];
lint combdp[1001][1001];
lint comb(int n, int c) {
  lint &ret = combdp[n][c];
  if (ret != -1) return ret;
  if (n == c || c == 0) return ret = 1;
  return ret = (comb(n - 1, c - 1) + comb(n - 1, c)) % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  memset(combdp, -1, sizeof combdp);
  cin >> N;
  for (int i = 0; i < N; i++) cin >> a[i];
  for (int i = N - 1; i >= 0; i--) {
    if (a[i] > 0 && a[i] < N - i) {
      dp[i] = comb(N - i - 1, a[i]);
      for (int j = i + a[i] + 1; j < N; j++) {
        (dp[i] += dp[j] * comb(j - i - 1, a[i])) %= MOD;
      }
    }
  }
  lint res = 0;
  for (int i = 0; i < N; i++) (res += dp[i]) %= MOD;
  cout << res << '\n';
  return 0;
}
