#include <bits/stdc++.h>
using namespace std;
template <typename t>
t in(t q) {
  cin >> q;
  return q;
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  os << "[";
  for (int i = 0; i < ((int)size(v)); ++i) {
    os << v[i];
    if (i != ((int)size(v)) - 1) os << ",";
  }
  os << "]";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto it : v) os << "(" << it.first << ":" << it.second << ")";
  return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v) {
  os << "(";
  os << v.first << "," << v.second << ")";
  return os;
}
const double PI = acos(-1);
long long a[(1 * 1005)], dp[(1 * 1005)];
long long com[(1 * 1005)][(1 * 1005)];
long long n;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << setprecision(25);
  for (__typeof((1 * 1005)) i = (0) - ((0) > ((1 * 1005)));
       i != ((1 * 1005)) - ((0) > ((1 * 1005)));
       i += 1 - 2 * ((0) > ((1 * 1005)))) {
    com[i][0] = 1;
    com[i][i] = 1;
  }
  for (__typeof((1 * 1005)) i = (1) - ((1) > ((1 * 1005)));
       i != ((1 * 1005)) - ((1) > ((1 * 1005)));
       i += 1 - 2 * ((1) > ((1 * 1005)))) {
    for (__typeof(i) j = (1) - ((1) > (i)); j != (i) - ((1) > (i));
         j += 1 - 2 * ((1) > (i))) {
      com[i][j] = (com[i - 1][j - 1] + com[i - 1][j]) % (998244353);
    }
  }
  cin >> n;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    cin >> a[i];
  }
  for (__typeof(0) first = (n) - ((n) > (0)); first != (0) - ((n) > (0));
       first += 1 - 2 * ((n) > (0))) {
    if (a[first] <= 0) continue;
    if (a[first] > n - first - 1) continue;
    for (int i = first + a[first] + 1; i <= n; ++i) {
      if (i == n) {
        dp[first] += com[i - first - 1][a[first]];
        dp[first] %= (998244353);
        continue;
      }
      dp[first] += com[i - first - 1][a[first]] * dp[i];
      dp[first] %= (998244353);
    }
  }
  long long sum = 0;
  for (__typeof(n) i = (0) - ((0) > (n)); i != (n) - ((0) > (n));
       i += 1 - 2 * ((0) > (n))) {
    sum += dp[i];
    sum %= (998244353);
  }
  cout << sum;
  return 0;
}
