#include <bits/stdc++.h>
using namespace std;
int spf[10000001];
long long int fac[200005];
long long int comb[1010][1010];
void combfun();
void sieve(int n);
int expo(int base, int exponent);
long long int power(long long int x, long long int y, long long int p);
long long int modInverse(long long int n, long long int p);
long long int nCrModPFormat(long long int n, long long int r, long long int p);
int lps(string s);
long long int dp[1010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  combfun();
  while (t--) {
    long long int n;
    cin >> n;
    long long int a[n];
    for (int i = 0; i < n; i++) {
      cin >> a[i];
    }
    dp[n] = 1;
    long long int ans = 0;
    for (long long int i = n - 1; i >= 0; i--) {
      if (a[i] < 1) continue;
      for (long long int j = i + a[i] + 1; j <= n; j++) {
        dp[i] += (dp[j] * comb[j - i - 1][a[i]]) % 998244353;
        dp[i] %= 998244353;
      }
      ans += dp[i];
      ans %= 998244353;
    }
    cout << ans % 998244353 << endl;
  }
  cerr << "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << "ms"
       << '\n';
  return 0;
}
void combfun() {
  for (int i = 1; i < 1010; i++) {
    for (int j = 0; j <= i; j++) {
      if (j == 0 or i == j) {
        comb[i][j] = 1;
      } else {
        comb[i][j] = comb[i - 1][j] + comb[i - 1][j - 1];
        comb[i][j] %= 998244353;
      }
    }
  }
}
int expo(int base, int exponent) {
  long long int ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (ans * base) % 998244353;
    base = (base * base) % 998244353;
    exponent >>= 1;
  }
  return ans % 998244353;
}
void sieve(int n) {
  spf[1] = 1;
  for (int i = 2; i <= n; i++) spf[i] = i;
  for (int i = 4; i <= n; i += 2) spf[i] = 2;
  for (int i = 3; i * i <= n; i++) {
    if (spf[i] == i) {
      for (int j = i * i; j <= n; j += i) {
        if (spf[j] == j) spf[j] = i;
      }
    }
  }
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long int modInverse(long long int n, long long int p) {
  return power(n, p - 2, p);
}
long long int nCrModPFormat(long long int n, long long int r, long long int p) {
  fac[0] = 1;
  for (int i = 1; i < 200005; i++) {
    fac[i] = (fac[i - 1] * i) % 998244353;
  }
  if (r == 0) return 1;
  return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) %
         p;
}
int lps(string s) {
  int n = s.size();
  int lps[n];
  lps[0] = 0;
  int i = 1;
  int j = 0;
  while (i < n) {
    if (s[i] == s[j]) {
      j++;
      lps[i] = j;
      i++;
    } else {
      if (j) {
        j = lps[j - 1];
      } else {
        lps[i] = 0;
        i++;
      }
    }
  }
  return min(n / 2, lps[n - 1]);
}
