#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int MOD = 998244353;
const int SZ = 1e3 + 1;
int c[SZ][SZ], a[SZ], dp[SZ];
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 1; i < SZ; i++) c[i][1] = i;
  for (int i = 2; i < SZ; i++)
    for (int j = 2; j < SZ; j++)
      c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
  for (int i = 0; i < n; i++) {
    if (a[i] <= 0) continue;
    for (int j = i + a[i]; j < n; j++)
      dp[j + 1] = (((long long)dp[i] + 1) * c[j - i][a[i]] + dp[j + 1]) % MOD;
  }
  cout << dp[n];
  return 0;
}
