#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353LL;
long long n;
long long a[1005];
long long dpc[1001][1001];
long long dp[1001];
long long C(long long n, long long r) {
  if (r < 0 || r > n || n <= 0) return 0;
  if (n == r || r == 0) return 1;
  if (dpc[n][r] != -1) return dpc[n][r];
  return dpc[n][r] = (C(n - 1, r) + C(n - 1, r - 1)) % MOD;
}
int main() {
  cin >> n;
  for (long long i = (long long)(1); i <= (long long)(n); i++) cin >> a[i];
  memset(dpc, -1, sizeof dpc);
  memset(dp, 0, sizeof dp);
  dp[n + 1] = 1;
  for (long long i = (long long)(n); i >= (long long)(1); i--) {
    if (a[i] <= 0 || a[i] > n - i) continue;
    for (long long j = (long long)(i + 1); j <= (long long)(n + 1); j++) {
      dp[i] += C(j - i - 1, a[i]) * dp[j];
      dp[i] %= MOD;
    }
  }
  long long ans = 0;
  for (long long i = (long long)(1); i <= (long long)(n); i++)
    ans = (ans + dp[i]) % MOD;
  cout << ans;
}
