#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e3 + 1;
const long long MOD = 998244353;
long long coeff[MAX][MAX];
void cal_coeff(int limit) {
  int i, j;
  for (i = 1; i <= limit; i++) {
    coeff[i][0] = coeff[i][i] = 1;
    for (j = 1; j < i; j++)
      coeff[i][j] = (coeff[i - 1][j - 1] + coeff[i - 1][j]) % MOD;
  }
}
int main() {
  long long n;
  long long arr[MAX];
  long long dp[MAX] = {0};
  long long i, j, k;
  cin >> n;
  cal_coeff(n);
  for (i = 0; i < n; i++) cin >> arr[i];
  dp[n] = 1;
  for (i = n - 2; i >= 0; i--) {
    if ((arr[i] > 0) && (arr[i] <= (n - 1 - i))) {
      for (j = arr[i]; j + i < n; j++) {
        dp[i] += ((coeff[j][arr[i]]) * dp[i + j + 1]);
        dp[i] %= MOD;
      }
    }
  }
  long long ans = 0;
  for (i = 0; i < n; i++) ans = (ans + dp[i]) % MOD;
  cout << ans << endl;
}
