#include <bits/stdc++.h>
using namespace std;
long long a, b, c, d = 0, i, z = 0, pref[300000], pref2[300000], x1[300000],
                   MAX = 0, MIN, res = 0, x = 0, p = 998244353, good[10000],
                   cehka[1015][1015];
vector<pair<long long, bool>> vec1;
void fun(long long v) {
  if (x1[v] <= a + 1) {
    pref[v] = cehka[a + 1 - v - 1][x1[v] - v - 1];
  }
  for (long long i = x1[v]; i <= a; i++) {
    pref[v] = (pref[v] + cehka[i - v - 1][x1[v] - v - 1] * (pref[i])) % p;
  }
}
signed main() {
  string s;
  cin >> a;
  for (long long i = 0; i <= a + 10; i++) {
    cehka[i][0] = 1;
    for (long long j = 1; j <= i; j++) {
      cehka[i][j] = (cehka[i - 1][j - 1] + cehka[i - 1][j]) % p;
    }
  }
  for (long long i = 1; i <= a; i++) {
    cin >> b;
    if (b > 0) {
      x1[i] = i + b + 1;
    } else {
      x1[i] = 1000000;
    }
  }
  for (long long i = a; i > 0; i--) {
    fun(i);
    res += pref[i];
    res = res % p;
  }
  cout << res;
  cin >> a;
  return 0;
}
