#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long inf = 4e18;
const long long N = 1e3 + 5;
long long ncr[N][N];
long long dp[N];
long long arr[N];
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tt = 1;
  while (tt--) {
    long long n;
    cin >> n;
    for (long long i = 0; i < n; ++i) cin >> arr[i];
    for (long long i = 1; i <= n; ++i) {
      ncr[i][0] = ncr[i][i] = 1;
      for (long long j = 1; j < i; ++j) {
        (ncr[i][j] = ncr[i - 1][j - 1] + ncr[i - 1][j]) %= mod;
      }
    }
    dp[n] = 1;
    long long ans = 0;
    for (long long i = n - 1; i >= 0; --i) {
      if (arr[i] > 0) {
        for (long long j = i + 1 + arr[i]; j <= n; ++j) {
          (dp[i] += dp[j] * (ncr[j - i - 1][arr[i]])) %= mod;
        }
      }
      (ans += dp[i]) %= mod;
    }
    cout << ans << "\n";
  }
  return 0;
}
