#include <bits/stdc++.h>
using namespace std;
long long modF = 998244353;
struct mi {
  long long val;
  explicit operator int() const { return val; }
  mi() : val(0) {}
  mi(long long v) : val(v % modF) {}
};
mi operator+(const mi& a, const mi& b) { return (a.val + b.val) % modF; }
mi operator*(const mi& a, const mi& b) { return (a.val * b.val) % modF; }
mi operator-(const mi& a, const mi& b) { return (a.val - b.val + modF) % modF; }
int n, a[1000];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = (0); i < (n); i++) {
    cin >> a[i];
  }
  mi dp[n][n];
  for (int i = (0); i < (n); i++) {
    for (int j = (0); j < (n); j++) {
      if (i == 0) {
        if (j == 0) {
          dp[i][j] = 1;
        } else if (a[i] > 0 && j == a[i]) {
          dp[i][j] = 1;
        }
      } else {
        dp[i][j] = dp[i - 1][j];
        if (j != n - 1) dp[i][j] = dp[i][j] + dp[i - 1][j + 1];
        if (a[i] > 0 && a[i] == j) dp[i][j] = dp[i][j] + dp[i - 1][0];
      }
    }
  }
  cout << int(dp[n - 1][0]) - 1 << '\n';
  return 0;
}
