#include <bits/stdc++.h>
using namespace std;
const long long Mod = 998244353;
const int N = 1e3 + 10;
long long dp[N][N * 2][2], n, a[N];
long long Rec(int i, int k, bool Taken) {
  if (i == n + 1 && !k && Taken) return 1;
  if (i == n + 1) return 0;
  if (dp[i][k][Taken] != -1) return dp[i][k][Taken];
  long long Res = 0;
  if (a[i] > 0 && a[i] <= N && !k) Res += Rec(i + 1, a[i], 1);
  if (k) Res += Rec(i + 1, k - 1, Taken);
  Res += Rec(i + 1, k, Taken);
  Res %= Mod;
  return dp[i][k][Taken] = Res;
}
int main() {
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << Rec(1, 0, 0);
  return 0;
}
