#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 5;
const int mod = 998244353;
int c[N][N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  c[0][0] = 1;
  for (int i = 1; i < N; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) {
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
    }
  }
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> dp(n, 0);
  vector<int> pre(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      if (a[j] > i - j || a[j] <= 0) continue;
      int tot = 1;
      if (j) tot += pre[j - 1];
      if (tot >= mod) tot -= mod;
      dp[i] += (1ll * tot * c[i - j - 1][a[j] - 1]) % mod;
      if (dp[i] >= mod) dp[i] -= mod;
    }
    pre[i] = dp[i];
    if (i) pre[i] += pre[i - 1];
    if (pre[i] >= mod) pre[i] -= mod;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += dp[i];
    if (ans >= mod) ans -= mod;
  }
  cout << ans;
  return 0;
}
