#include <bits/stdc++.h>
using namespace std;
long long int a[1010];
long long int dp[1010][1010];
long long int dp1[1010];
int n;
long long int mod = 998244353;
long long int com(long long int n, long long int r) {
  if (n == r) return 1;
  if (r == 1) return n;
  if (dp[n][r] != -1) return dp[n][r];
  return dp[n][r] = (com(n - 1, r) + com(n - 1, r - 1)) % mod;
}
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  memset(dp, -1, sizeof dp);
  dp1[n + 1] = 1;
  long long int sum = 0;
  for (int i = n; i >= 1; i--) {
    if (a[i] <= 0) continue;
    for (int j = i + a[i] + 1; j <= n + 1; j++) {
      dp1[i] = (dp1[i] + (com(j - i - 1, a[i]) * dp1[j]) % mod) % mod;
    }
    sum = (sum + dp1[i]) % mod;
  }
  cout << sum << endl;
  return 0;
}
