#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int mod = 998244353;
const int MAXN = 1007;
long long a[MAXN];
long long dp[MAXN];
long long dp2[MAXN];
long long C[MAXN][MAXN];
int n;
long long solve(long long pos);
long long solveSum(long long pos) {
  if (pos >= n) return 0;
  if (dp2[pos] != -1) return dp2[pos];
  dp2[pos] = (solve(pos) + solveSum(pos + 1)) % mod;
  return dp2[pos];
}
long long solve(long long pos) {
  if (pos >= n) return 0;
  if (a[pos] <= 0) return 0;
  if (pos + a[pos] >= n) return 0;
  if (dp[pos] != -1) return dp[pos];
  dp[pos] = 0;
  for (int i = a[pos]; i < n; ++i) {
    if (pos + i < n) {
      dp[pos] += C[i - 1][a[pos] - 1] * (solveSum(pos + i + 1) + 1);
      dp[pos] %= mod;
    }
  }
  return dp[pos];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < MAXN; ++i) {
    C[i][i] = C[i][0] = 1;
    for (int c = 1; c < i; ++c) {
      C[i][c] = C[i - 1][c] + C[i - 1][c - 1];
      C[i][c] %= mod;
    }
  }
  memset(dp, -1, sizeof(dp));
  memset(dp2, -1, sizeof(dp2));
  cout << solveSum(0) << endl;
  return 0;
}
