#include <bits/stdc++.h>
using namespace std;
const int MaxN = 1e3;
const int Inf = 1 << 30;
const long long mod = 998244353;
long long a[MaxN + 5], dp[MaxN + 5];
long long C[MaxN + 5][MaxN + 5];
int main() {
  long long n, sum, pos, ans;
  C[1][0] = 1LL;
  C[1][1] = 1LL;
  for (long long i = 2; i <= MaxN; i++) {
    C[i][0] = 1LL;
    C[i][1] = i;
    for (long long j = 0; j <= i / 2; j++) {
      if (j == 0)
        C[i][j] = 1;
      else if (j == 1)
        C[i][j] = i;
      else
        C[i][j] = C[i - 1][j - 1] + C[i - 1][j];
      C[i][j] %= mod;
      C[i][i - j] = C[i][j];
    }
  }
  while (~scanf("%I64d", &n)) {
    for (long long i = 1; i <= n; i++) scanf("%I64d", &a[i]);
    dp[n + 1] = 1LL;
    ans = 0LL;
    for (long long i = n; i >= 1; i--) {
      dp[i] = 0LL;
      if (a[i] <= 0LL) continue;
      sum = 1LL;
      pos = a[i];
      for (long long j = i + a[i]; j <= n; j++) {
        dp[i] += (C[pos][a[i]] * dp[j + 1]) % mod;
        dp[i] %= mod;
        pos++;
      }
      ans += dp[i];
      ans %= mod;
    }
    printf("%I64d\n", ans);
  }
  return 0;
}
