#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll S = 1000LL;
const ll MOD = 998244353LL;
ll dp[S + 10], acc[S + 10], A[S + 10];
ll comb[S + 10][S + 10];
int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  for (int i = 0; i <= S; i++) {
    comb[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    if (i + A[i] >= N || A[i] <= 0)
      dp[i] = 0;
    else {
      for (int j = i + A[i]; j < N; j++) {
        ll n = j - i - (j != i + A[i]), r = A[i] - (j != i + A[i]);
        ll ad = comb[n][r] * (1 + acc[j + 1]) % MOD;
        (dp[i] += ad) %= MOD;
      }
    }
    acc[i] = (acc[i + 1] + dp[i]) % MOD;
  }
  ll ans = acc[0] % MOD;
  printf("%lld\n", ans);
  return 0;
}
