#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
long long int ncr[1004][1004];
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  for (int i = 0; i < 1001; i++) {
    ncr[i][0] = ncr[i][i] = 1;
    for (int j = 1; j < i; j++) {
      ncr[i][j] = ncr[i - 1][j - 1] + ncr[i - 1][j];
      ncr[i][j] %= mod;
    }
  }
  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long int dp[n];
  dp[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] <= 0) {
      dp[i] = 0;
      continue;
    }
    int k = a[i] + 1;
    if (i + k > n) {
      dp[i] = 0;
      continue;
    }
    dp[i] = ncr[n - i - 1][k - 1];
    for (int j = i + k; j < n; j++) {
      dp[i] += (dp[j] * (ncr[j - i - 1][k - 1])) % mod;
      dp[i] %= mod;
    }
  }
  long long int sum = 0;
  for (int i = 0; i < n; i++) {
    sum += dp[i];
    sum %= mod;
  }
  cout << sum << "\n";
  return 0;
}
