#include <bits/stdc++.h>
int n, a[1002], dp[1002], C[1002][1002];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 0; i <= n; ++i) C[i][0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= i; ++j)
      C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % 998244353;
  dp[n + 1] = 1;
  for (int i = n; i; --i) {
    if (a[i] <= 0) {
      dp[i] = 0;
      continue;
    }
    for (int j = i + a[i] + 1; j <= n + 1; ++j) {
      dp[i] += 1LL * dp[j] * C[j - i - 1][a[i]] % 998244353;
      dp[i] %= 998244353;
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) ans += dp[i], ans %= 998244353;
  printf("%d\n", ans);
}
