#include <bits/stdc++.h>
using namespace std;
const int maxn = 1100;
const int mod = 998244353;
long long c[maxn][maxn], dp[maxn];
int a[maxn];
void init(int n) {
  for (int i = 0; i <= n; i++) {
    c[i][0] = c[i][i] = 1;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
}
int main(void) {
  int n;
  scanf("%d", &n);
  init(n);
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  dp[n + 1] = 1;
  long long ans = 0;
  for (int i = n; i >= 1; i--) {
    if (a[i] <= 0) continue;
    for (int j = i + a[i] + 1; j <= n + 1; j++) {
      dp[i] = (dp[i] + c[j - i - 1][a[i]] * dp[j]) % mod;
    }
    ans = (ans + dp[i]) % mod;
  }
  printf("%lld\n", ans);
  return 0;
}
