#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.0);
double fRand(double fMin, double fMax) {
  double f = (double)rand() / RAND_MAX;
  return fMin + f * (fMax - fMin);
}
template <class T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <class T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
int n, a[1005], dp[1005], c[1005][1005];
int main() {
  scanf("%d", &n);
  for (int i = (1); i <= (n); ++i) scanf("%d", &a[i]);
  c[0][0] = 1;
  for (int i = (1); i <= (n); ++i) {
    c[i][0] = 1;
    for (int j = (1); j <= (i); ++j)
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % 998244353;
  }
  int ans = 0;
  dp[n + 1] = 1;
  for (int i = (n); i >= (1); --i) {
    if (a[i] > 0 && a[i] <= n - i) {
      for (int j = (i + a[i]); j <= (n); ++j)
        dp[i] = (dp[i] + 1LL * dp[j + 1] * c[j - i][a[i]]) % 998244353;
    }
    ans = (ans + dp[i]) % 998244353;
  }
  printf("%d", ans);
  return 0;
}
