#include <bits/stdc++.h>
using namespace std;
const int N = 1005, mod = 998244353;
long long dp[N], ans;
int c[N][N], n, a[N];
inline void init() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
}
inline void solve() {
  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] + c[i - 1][j - 1]) % mod;
    }
  }
  dp[n + 1] = 1;
  for (int i = n; i; i--) {
    if (a[i] > 0) {
      for (int j = a[i] + i + 1; j <= n + 1; j++) {
        dp[i] = (dp[i] + 1ll * c[j - i - 1][a[i]] * dp[j] % mod) % mod;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    ans = (ans + dp[i]) % mod;
  }
  printf("%I64d\n", ans);
}
int main() {
  init();
  solve();
  return 0;
}
