#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
const long long du = 998244353;
long long f[maxn][maxn], c[maxn][maxn];
int a[maxn];
int n;
void nhap() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
}
void khoitao() {
  c[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= n; j++) c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % du;
  }
}
void xuli() {
  f[n + 1][1] = 1;
  for (int i = n; i >= 1; i--) {
    f[i][0] = f[i + 1][1] + f[i + 1][0];
    if (a[i] > 0) {
      for (int j = i + a[i]; j <= n; j++)
        f[i][1] = (f[i][1] + c[j - i][a[i]] * f[j + 1][1]) % du;
    }
  }
}
int main() {
  nhap();
  khoitao();
  xuli();
  cout << (f[1][1] + f[1][0] + du - 1) % du;
}
