#include <bits/stdc++.h>
using namespace std;
long long int dp[1005], a[1005], n;
int C[1002][1002];
long long int f(long long int i) {
  if (dp[i] != -1) return dp[i];
  if (i == n + 1) {
    dp[i] = 1;
    return 1;
  }
  if (a[i] <= 0) {
    dp[i] = 0;
    return dp[i];
  }
  long long int val = 0;
  for (int j = i + a[i] + 1; j <= n + 1; j++) {
    f(j);
    val = (val + (C[j - i - 1][a[i]] * dp[j]) % 998244353) % 998244353;
  }
  dp[i] = val;
  return dp[i];
}
int main() {
  for (int i = 0; i <= 1003; i++) dp[i] = -1;
  cin >> n;
  for (int i = 0; i < n; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++)
      C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % 998244353;
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) f(i);
  long long int sum = 0;
  for (int i = 1; i <= n; i++) sum = (sum + dp[i]) % 998244353;
  cout << sum;
}
