#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
const long long N = 1e3 + 1;
long long dp[N][N];
long long a[N];
long long n;
long long add(long long a, long long b) {
  return ((a % mod) + (b % mod)) % mod;
}
long long sub(long long a, long long b) {
  return (((a % mod) - (b % mod)) + mod) % mod;
}
long long solve(long long idx, long long p) {
  if (idx == n + 1) {
    if (p == 0) return 1;
    return 0;
  }
  if (dp[idx][p] != -1) return dp[idx][p];
  long long ans = 0;
  ans = solve(idx + 1, p);
  if (p == 0) {
    long long rem = n - idx;
    if (a[idx] >= 1 && a[idx] <= rem) ans = add(ans, solve(idx + 1, a[idx]));
  } else {
    ans = add(ans, solve(idx + 1, p - 1));
  }
  dp[idx][p] = ans;
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (long long i = 1; i <= n; i++) cin >> a[i];
  long long ans = solve(1, 0);
  ans = sub(ans, 1);
  cout << ans;
}
