#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
long long n;
long long a[1111], ps[1111], dp[1111];
long long choose[1111][1111];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  choose[0][0] = 1;
  for (int i = 1; i < 1111; i++) {
    choose[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      choose[i][j] = (choose[i - 1][j] + choose[i - 1][j - 1]) % mod;
    }
  }
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = n - 1; i > 0; i--) {
    if (a[i] > 0 and i + a[i] <= n) {
      for (int j = i + a[i]; j <= n; j++) {
        long long tmp = choose[j - i - 1][a[i] - 1] * (1ll + ps[j + 1]);
        tmp %= mod;
        dp[i] = (dp[i] + tmp) % mod;
      }
    }
    ps[i] = (ps[i + 1] + dp[i]) % mod;
  }
  cout << ps[1] << endl;
  return 0;
}
