#include <bits/stdc++.h>
using namespace std;
long long inf = 2147483647;
const long long ll = 9223372036854775807, ninf = 1000000000;
const double eps = 1e-6;
const long long nll = 1000000000000000000;
class CircleOrder {
 public:
  string firstOrder(string s) {}
};
long long C[1005][1005] = {};
long long dp[1005] = {};
const int MOD = 998244353;
int main() {
  for (int i = 0; i < 1005; i++) {
    C[i][0] = C[i][i] = 1;
    for (int j = 1; j < i; j++) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
      C[i][j] %= MOD;
    }
  }
  int a;
  while (cin >> a) {
    int A[1005] = {};
    for (int i = 0; i < a; i++) cin >> A[i];
    dp[a] = 1;
    for (int i = a - 1; i >= 0; i--) {
      if (A[i] <= 0) continue;
      for (int j = i + A[i] + 1; j <= a; j++) {
        dp[i] += (dp[j]) * (C[j - i - 1][A[i]]);
        dp[i] %= MOD;
      }
    }
    long long ans = 0;
    for (int i = 0; i < a; i++) {
      ans += dp[i];
      ans %= MOD;
    }
    cout << ans << '\n';
  }
  return 0;
}
