#include <bits/stdc++.h>
using namespace std;
long long int N = 1009;
long long int C[1009][1009];
long long int mod = 998244353;
long long int dp[1009];
int main() {
  for (long long int i = 0; i < N; i++) {
    C[i][0] = C[i][i] = 1;
    for (long long int j = 1; j < i; j++)
      C[i][j] = (C[i - 1][j] % mod + C[i - 1][j - 1] % mod) % mod;
  }
  long long int n, ans = 0;
  cin >> n;
  vector<long long int> ar(n + 1);
  for (long long int i = 0; i < n; i++) cin >> ar[i], dp[i] = 0;
  dp[n] = 1;
  for (long long int i = n - 1; i >= 0; i--) {
    if (ar[i] <= 0) continue;
    for (long long int j = i + ar[i] + 1; j <= n; j++) {
      dp[i] += (dp[j] % mod * C[j - i - 1][ar[i]] % mod) % mod;
      dp[i] %= mod;
    }
  }
  for (long long int i = 0; i < n; i++) {
    ans += dp[i];
    ans %= mod;
  }
  cout << ans << endl;
}
