#include <bits/stdc++.h>
using namespace std;
long long modulo(long long base, long long exponent, long long modulus);
long long choose(long long n, long long k);
long long inverse(long long a, long long m);
long long chose[1005][1005];
long long done[1005];
long long suffix[1005];
void build() {
  for (int i = 0; i < 1005; i++) chose[i][0] = 1;
  for (int i = 1; i < 1005; i++) {
    for (int j = 1; j <= i; j++) {
      chose[i][j] = (chose[i - 1][j] + chose[i - 1][j - 1]) % 998244353;
    }
  }
}
int main() {
  build();
  long long n;
  cin >> n;
  vector<long long> a(n + 1);
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = n; i > 0; i--) {
    long long x = a[i];
    if (x > 0 && i + x <= n) {
      done[i] = (done[i] + chose[n - i][x]) % 998244353;
      for (int j = i + x + 1; j <= n; j++) {
        done[i] =
            (done[i] + (done[j] * chose[j - i - 1][x]) % 998244353) % 998244353;
      }
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + done[i]) % 998244353;
  }
  cout << ans << endl;
  return 0;
}
long long modulo(long long base, long long exponent, long long modulus) {
  if (modulus == 1) return 0;
  long long result = 1;
  base = base % modulus;
  while (exponent > 0) {
    if (exponent % 2 == 1) {
      result = (result * base) % modulus;
    }
    exponent = exponent >> 1;
    base = (base * base) % modulus;
  }
  return result;
}
long long choose(long long n, long long k) {
  if (k == 0) return 1;
  return (n * choose(n - 1, k - 1)) / k;
}
void EE(long long a, long long b, long long &co1, long long &co2) {
  if (a % b == 0) {
    co1 = 0;
    co2 = 1;
    return;
  }
  EE(b, a % b, co1, co2);
  long long temp = co1;
  co1 = co2;
  co2 = temp - co2 * (a / b);
}
long long inverse(long long a, long long m) {
  long long x, y;
  EE(a, m, x, y);
  if (x < 0) x += m;
  return x;
}
