#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 100;
const int mod = 998244353;
int c[N][N], dp[N], mm[N];
void pcal() {
  for (int i = 0; i < 1001; i++)
    for (int j = 0; j <= i; j++) {
      if (j == i || j == 0)
        c[i][j] = 1;
      else
        c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]);
      if (c[i][j] >= mod) c[i][j] -= mod;
    }
}
int comb(int n, int k) {
  if (k > n) return 0;
  return c[n][k];
}
int main() {
  pcal();
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> mm[i];
  int ans = 0;
  dp[n] = 1;
  for (int i = n - 1; i >= 0; i--)
    if (mm[i] > 0) {
      for (int j = i + mm[i] + 1; j <= n; j++) {
        dp[i] += (1LL * comb(j - i - 1, mm[i]) * dp[j]) % mod;
        if (dp[i] >= mod) dp[i] -= mod;
      }
      ans += dp[i];
      if (ans >= mod) ans -= mod;
    }
  cout << ans << endl;
  return 0;
}
