#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:10240000000,10240000000")
const int maxn = 1e3 + 80;
const int mod = 998244353;
long long dp[maxn];
long long a[maxn];
long long c[maxn][maxn];
void getc() {
  for (int i = 0; i < maxn; i++) c[i][0] = 1;
  for (int i = 1; i < maxn; i++)
    for (int j = 1; j <= i; j++)
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
}
int main() {
  getc();
  int n;
  while (~scanf("%d", &n)) {
    memset(dp, -1, sizeof(dp));
    for (int i = 1; i <= n; i++) scanf("%I64d", &a[i]);
    dp[n + 1] = 1;
    long long ans = 0;
    for (int i = n; i >= 1; i--) {
      if (a[i] <= 0 || a[i] > (n - i)) {
        dp[i] = 0;
        continue;
      }
      dp[i] = 0;
      for (int j = i + a[i]; j <= n; j++)
        dp[i] = (dp[i] + c[j - i][a[i]] * dp[j + 1] % mod) % mod;
      ans = (ans + dp[i]) % mod;
    }
    printf("%I64d\n", ans);
  }
}
