#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long dp[1002];
long long C[1002][1002];
int a[1001];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  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;
    }
  }
  for (int i = 1; i <= N; ++i) cin >> a[i];
  long long ans = 0;
  dp[N + 1] = 1;
  for (int i = N - 1; i >= 1; i--) {
    if (a[i] > N - i) continue;
    if (a[i] <= 0) continue;
    for (int j = i + a[i]; j <= N; ++j) {
      dp[i] += (C[j - i][a[i]] * dp[j + 1]) % mod;
      dp[i] %= mod;
    }
    ans = (dp[i] + ans) % mod;
  }
  cout << ans << '\n';
}
