#include <bits/stdc++.h>
using namespace std;
int n, a[1005];
long long f[1005], res, mod = 998244353, c[1005][1005];
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 0; i <= n; i++) {
    c[0][i] = c[i][i] = 1;
    for (int j = 1; j < i; j++) c[j][i] = (c[j - 1][i - 1] + c[j][i - 1]) % mod;
  }
  for (int i = n - 1; i >= 1; i--) {
    if (a[i] <= 0 || a[i] + i > n) continue;
    f[i] = c[a[i]][n - i];
    for (int j = i + a[i] + 1; j <= n; j++) {
      if (a[j] > 0) f[i] = (f[i] + c[a[i]][j - i - 1] * f[j]) % mod;
    }
    res = (res + f[i]) % mod;
  }
  cout << res;
}
