#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
const int N = 1005;
long long dp[1005];
int v[1005];
long long C[N + 1][N + 1];
int main() {
  C[0][0] = 1;
  for (int i = 1; i <= N; i++)
    for (int j = 0; j <= i; j++)
      C[i][j] = ((j - 1 >= 0 ? C[i - 1][j - 1] : 0) + C[i - 1][j]) % MOD;
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", v + i);
  }
  memset(dp, 0, sizeof dp);
  dp[n] = 1;
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = i; j < n; j++) {
      if (j - i < v[i]) continue;
      if (v[i] <= 0) continue;
      dp[i] = (dp[i] + dp[j + 1] * C[j - i][v[i]] % MOD) % MOD;
    }
    ans = (ans + dp[i]) % MOD;
  }
  cout << ans;
  return 0;
}
