#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long dp[1111], c[1111][1111];
int a[1111];
int n;
void init() {
  for (int i = 0; i < 1111; i++) c[i][0] = 1;
  for (int i = 1; i < 1111; i++) {
    for (int j = 1; j <= i; j++) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
  }
}
int main() {
  init();
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  dp[n - 1] = 0;
  int res = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] <= 0) {
      continue;
    }
    if (n - i >= a[i] + 1) dp[i] = (dp[i] + c[n - 1 - i][a[i]]) % mod;
    for (int j = a[i] + i + 1; j < n; j++) {
      dp[i] = (dp[i] + (c[j - i - 1][a[i]] * dp[j]) % mod) % mod;
    }
    res = (res + dp[i]) % mod;
  }
  cout << res << endl;
}
