#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int MAXN = 1009;
int n, a[MAXN], dp[MAXN], call[MAXN][MAXN];
void solve() {
  for (int i = 0; i < MAXN; i++) {
    call[i][0] = call[i][i] = 1;
    for (int j = 1; j < i; j++)
      call[i][j] = (call[i - 1][j] + call[i - 1][j - 1]) % 998244353;
  }
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  dp[n] = 1;
  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 * call[j - i - 1][a[i]]) % 998244353;
      dp[i] %= 998244353;
    }
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    res += dp[i];
    res %= 998244353;
  }
  cout << res << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t = 1;
  while (t--) {
    solve();
  }
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}
