#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
int n;
vector<long long> a, memo(1001, -1);
long long c[1001][1001];
long long dp(int pos) {
  long long &ret = memo[pos];
  if (ret != -1) return ret;
  ret = 0;
  long long val = a[pos];
  if (val <= 0) return ret;
  if (val + pos < n) ret = c[n - pos - 1][val];
  for (long long i = val + pos + 1; i < n; i++) {
    ret += c[i - pos - 1][val] * dp(i);
    ret %= mod;
  }
  return ret;
}
int main() {
  cin >> n;
  a.resize(n);
  for (auto &e : a) cin >> e;
  for (int i = 0; i < n; ++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]) % mod;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += dp(i);
    ans %= mod;
  }
  cout << ans;
  cin >> n;
}
