#include <bits/stdc++.h>
using namespace std;
int n;
int a[1005];
long long fac[1005];
long long dp[1005];
long long power(long long a, int k) {
  long long res = 1;
  while (k) {
    if (k & 1) res = (res * a) % 998244353;
    a = (a * a) % 998244353;
    k /= 2;
  }
  return res;
}
long long C(int x, int y) {
  long long res = fac[x];
  res = (res * power(fac[y], 998244353 - 2)) % 998244353;
  res = (res * power(fac[x - y], 998244353 - 2)) % 998244353;
  return res;
}
int main() {
  fac[0] = 1;
  for (int i = 1; i <= 1001; i++) fac[i] = (fac[i - 1] * i) % 998244353;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dp[n + 1] = 1;
  for (int i = n; i >= 1; i--) {
    if (a[i] <= 0 || i + a[i] > n) continue;
    for (int j = i + a[i]; j <= n; j++) {
      dp[i] = (dp[i] + C(j - i, a[i]) * dp[j + 1]) % 998244353;
    }
  }
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + dp[i]) % 998244353;
  }
  cout << ans;
  return 0;
}
