#include <bits/stdc++.h>
using namespace std;
long long dp[1005];
long long a[1005];
long long f[30005], in[30005], first[30005];
long long getncr(int N, int R) {
  if (N == R) return 1;
  if (N < R) return 0;
  if (R == 0) return 1;
  return ((((f[N] * first[R]) % 998244353 + 998244353) % 998244353 *
           first[N - R]) %
              998244353 +
          998244353) %
         998244353;
}
long long rec(long long i, long long n) {
  if (i > n) return 0;
  if (dp[i] != -1) return dp[i];
  long long ans = 0;
  if (i + a[i] > n) return dp[i] = rec(i + 1, n);
  if (a[i] > 0) {
    for (long long j = i + a[i], k = a[i]; j <= n; j++, k++)
      ans += ((rec(j + 1, n) + 1) * getncr(k - 1, a[i] - 1)) % 998244353,
          ans %= 998244353;
  }
  ans += rec(i + 1, n);
  ans %= 998244353;
  return dp[i] = ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  f[0] = f[1] = in[0] = in[1] = first[0] = first[1] = 1;
  int i, j;
  for (i = 2; i <= 30004; i++) {
    f[i] = (1ll * f[i - 1] * i) % 998244353;
    in[i] = (-((1ll) * (998244353 / i) * in[998244353 % i]) % 998244353 +
             998244353) %
            998244353;
    first[i] = (1ll * first[i - 1] * in[i]) % 998244353;
  }
  int n;
  cin >> n;
  for (i = 1; i <= n; i++) cin >> a[i], dp[i] = -1;
  cout << rec(1, n);
  return 0;
}
