#include <bits/stdc++.h>
using namespace std;
long long a[1007];
long long cnt[1007];
long long ncr[1007][1007];
long long MOD = 998244353;
int main() {
  long long n, res = 0, x;
  scanf("%I64d", &n);
  ;
  for (long long i = 1; i <= n; ++i) scanf("%I64d", &a[i]);
  ;
  for (int i = 0; i < 1000; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (i == 0 || j == 0)
        ncr[i][j] = 1;
      else
        ncr[i][j] = (ncr[i - 1][j] + ncr[i - 1][j - 1]) % MOD;
    }
  }
  for (long long i = n; i > 0; --i) {
    if ((a[i] > 0) && ((i + a[i]) <= n)) {
      x = ncr[n - i][a[i]];
      cnt[i] = x;
      for (long long j = i + a[i] + 1; j < n; ++j) {
        x = ncr[j - i - 1][a[i]];
        x = (x * cnt[j]) % MOD;
        cnt[i] = (cnt[i] + x) % MOD;
      }
    }
    res = (res + cnt[i]) % MOD;
  }
  cout << res;
  return 0;
}
