#include <bits/stdc++.h>
using namespace std;
long long T[1001][1001];
int main() {
  long long n;
  cin >> n;
  long long a[n];
  for (long long i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < 1001; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 || i == j)
        T[i][j] = 1;
      else
        T[i][j] = (T[i - 1][j] + T[i - 1][j - 1]) % 998244353;
    }
  }
  long long L[n + 1];
  L[n] = 1;
  for (long long i = n - 1; i >= 0; i--) {
    if (a[i] <= 0 || (i + a[i]) >= n) {
      L[i] = 0;
    } else {
      long long s = 0;
      for (long long k = i + a[i]; k < n; k++) {
        s = (s + (T[k - i][a[i]] * (L[k + 1])) % 998244353) % 998244353;
      }
      L[i] = s;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) ans = (ans + L[i]) % 998244353;
  cout << ans;
}
