#include <bits/stdc++.h>
using namespace std;
int a[1005];
long long dp[1005], c[1005][1005];
long long ans;
int mod = 998244353;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= 1000; i++) {
    for (int j = 1; j <= 1000; j++) {
      if (j == 1)
        c[i][j] = i;
      else
        c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  dp[n + 1] = 1;
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] <= 0 || a[i] + i > n) continue;
    for (int j = i + a[i] + 1; j <= n + 1; j++) {
      dp[i] += c[j - i - 1][a[i]] * dp[j];
      dp[i] %= mod;
    }
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += dp[i];
    sum %= mod;
  }
  cout << sum << endl;
  return 0;
}
