#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 10;
const int MOD = 998244353;
const int INF = 10;
int fact[MAXN], invfact[MAXN];
int add(int a, int b) {
  int sum = a + b;
  return (sum >= MOD ? sum -= MOD : (sum < 0 ? sum += MOD : sum));
}
int mul(int a, int b) { return 1LL * a * b % MOD; }
int pwr(int a, int b) {
  return (!b ? 1
             : (b & 1 ? 1LL * a * pwr(1LL * a * a % MOD, b >> 1) % MOD
                      : pwr(1LL * a * a % MOD, b >> 1) % MOD));
}
int inv(int x) { return pwr(x, MOD - 2); }
void first() {
  fact[0] = 1;
  for (int i = 1; i < MAXN; i++) fact[i] = mul(fact[i - 1], i);
  for (int i = 0; i < MAXN; i++) invfact[i] = inv(fact[i]);
}
int C(int n, int k) { return mul(mul(fact[n], invfact[k]), invfact[n - k]); }
int P(int n, int k) { return mul(fact[n], invfact[n - k]); }
int n, a[MAXN], dp[MAXN];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  first();
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] <= 0 || a[i] + i - 1 > n - 1) {
      continue;
    }
    for (int j = n - 1; j >= a[i] + i; j--) {
      dp[i] = add(dp[i], mul(dp[j + 1], C(j - i, a[i])));
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans = add(ans, dp[i]);
  }
  cout << ans;
  return 0;
}
