#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 1e3 + 31;
int f[maxn][maxn];
signed main() {
  int n;
  cin >> n;
  vector<int> a(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < n; j++) {
      f[i][j] = (f[i - 1][j] + f[i - 1][j + 1]) % mod;
    }
    if (a[i] > 0 && a[i] < n) {
      f[i][a[i]] = (f[i - 1][0] + f[i][a[i]] + 1) % mod;
    }
  }
  cout << f[n][0] << '\n';
  return 0;
}
