#include <bits/stdc++.h>
using namespace std;
template <class T>
T sqr(T x) {
  return x * x;
}
const long long mod = 998244353;
const int maxn = 2001;
long long c[maxn][maxn];
long long dp[maxn];
int n;
int s[maxn];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d", &s[i]);
  c[0][0] = 1;
  for (int i = 1; i <= 1000; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j <= i - 1; j++) {
      c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
    }
  }
  dp[n + 1] = 1;
  long long ans = 0;
  for (int i = n - 1; i > 0; --i) {
    if (s[i] <= 0) continue;
    for (int j = i + 1; j <= n + 1; j++) {
      if (j - i - 1 < s[i]) continue;
      (dp[i] += (dp[j] * c[j - i - 1][s[i]])) %= mod;
    }
    (ans += (dp[i])) %= mod;
  }
  cout << ans << endl;
}
