#include <bits/stdc++.h>
using namespace std;
int c[1010][1010];
int rec[1010];
long long dp[1010];
int sum[1010];
int main() {
  int i, j;
  int n;
  scanf("%d", &n);
  for (i = 0; i <= n; i++) {
    c[i][0] = 1;
    c[i][1] = i;
    c[i][i] = 1;
  }
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= n; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % 998244353;
    }
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", rec + i);
  }
  for (i = n; i >= 1; i--) {
    if (rec[i] > 0 && rec[i] <= n - i) {
      for (j = i + rec[i]; j <= n; j++) {
        dp[i] = (dp[i] + c[j - i - 1][rec[i] - 1] * 1LL * (1 + sum[j + 1])) %
                998244353;
      }
    }
    sum[i] = (sum[i + 1] + dp[i]) % 998244353;
  }
  printf("%d\n", sum[1]);
  return 0;
}
