#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  long long n;
  cin >> n;
  long long choose[1001][1001] = {}, a[n];
  for (long long &i : a) cin >> i;
  for (long long i = 0; i <= n; ++i) choose[i][0] = 1;
  for (long long i = 1; i <= n; ++i) {
    for (long long j = 1; j <= i; ++j) {
      choose[i][j] = (choose[i - 1][j - 1] + choose[i - 1][j]) % MOD;
    }
  }
  long long dp[n + 1], ans = 0;
  dp[n] = 1;
  for (long long i = n - 1; i >= 0; --i) {
    dp[i] = 0;
    if (a[i] <= 0) continue;
    for (long long j = i + a[i]; j < n; ++j) {
      dp[i] = (dp[i] + choose[j - i][a[i]] * dp[j + 1]) % MOD;
    }
    ans = (ans + dp[i]) % MOD;
  }
  cout << ans << "\n";
}
