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