#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int t[1005], n, x;
int main() {
  cin >> n;
  t[0] = 1;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    x = t[0];
    for (int j = 0; j <= n; j++) t[j] = (t[j] + t[j + 1]) % mod;
    if (a > 0 && a <= n) t[a] = (t[a] + x) % mod;
  }
  cout << (t[0] - 1 + mod) % mod << endl;
  return 0;
}
