#include <bits/stdc++.h>
const long long oo = 1000000000000000000;
const long long PI = 3.1415926535897932384626;
const long long MOD = 998244353;
long long N;
std::vector<long long> val;
long long dp[1002];
long long combi[1002][1002];
void pascal() {
  long long i = 0, j = 0;
  for (i = 0; i < N + 1; i++) {
    combi[i][0] = combi[i][i] = 1;
  }
  for (i = 1; i < N + 1; i++) {
    for (j = 1; j < i; j++) {
      combi[i][j] = combi[i - 1][j - 1] + combi[i - 1][j];
      combi[i][j] = combi[i][j] % MOD;
    }
  }
}
int32_t main() {
  scanf("%lld", &N);
  long long a, i, j;
  for (i = 0; i < N; i++) {
    scanf("%lld", &a);
    val.push_back(a);
  }
  pascal();
  dp[N] = 1;
  for (i = N - 1; i >= 0; i--) {
    if (val[i] > 0) {
      for (j = i + val[i] + 1; j < N + 1; j++) {
        dp[i] += (dp[j]) * combi[j - i - 1][val[i]];
        dp[i] = dp[i] % MOD;
      }
    }
  }
  long long r = 0;
  for (i = 0; i < N; i++) {
    r += dp[i];
    r = r % MOD;
  }
  printf("%lld\n", r);
}
