#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
const int mod = 998244353;
int a[N], dp[N], c[N][N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i < N; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 0; j < i; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  int n;
  cin >> n;
  dp[n] = 1;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] <= 0) continue;
    for (int j = i + a[i] + 1; j <= n; j++) {
      dp[i] += (dp[j] * 1LL * c[j - i - 1][a[i]]) % mod;
      dp[i] %= mod;
    }
  }
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += dp[i];
    sum %= mod;
  }
  cout << sum << endl;
}
