#include <bits/stdc++.h>
using namespace std;
vector<long long> fact(1001);
long long power(long long a, long long b) {
  if (b == 0) return 1;
  long long ans = power(a, b / 2);
  ans = (ans % 998244353 * ans % 998244353) % 998244353;
  if (b % 2 == 1) return (ans * a) % 998244353;
  return ans;
}
long long inverse(long long a, long long p) { return power(a, p - 2); }
long long ncr(long long n, long long r) {
  long long ans = fact[n];
  ans = (ans * inverse(fact[r], 998244353)) % 998244353;
  ans = (ans * inverse(fact[n - r], 998244353)) % 998244353;
  return ans;
}
int32_t main() {
  ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  fact[0] = 1;
  for (long long i = 1; i < 1001; i++) fact[i] = (fact[i - 1] * i) % 998244353;
  long long t = 1;
  while (t--) {
    long long n, ans = 0;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i < n; i++) cin >> a[i];
    vector<long long> dp(n + 1, 0);
    for (long long i = n - 1; i >= 0; i--) {
      if (a[i] <= 0) {
        dp[i] = ans;
        continue;
      }
      for (long long j = i + a[i]; j < n; j++) {
        long long x = ncr(j - i - 1, a[i] - 1);
        ans = (ans + x) % 998244353;
        ans = (ans + (x * dp[j + 1]) % 998244353) % 998244353;
      }
      dp[i] = ans;
    }
    cout << ans << endl;
  }
  return 0;
}
