#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int c[1005][1005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  c[0][0] = 1;
  for (int i = 1; i <= 1000; i++) {
    c[i][0] = c[i][i] = 1;
    for (int j = 1; j < i; j++) {
      c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
      if (c[i][j] >= mod) c[i][j] -= mod;
    }
  }
  int n;
  cin >> n;
  vector<int> a(n);
  for (int& x : a) cin >> x;
  vector<int> dp(n);
  dp[n - 1] = 0;
  int ans = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (a[i] <= 0 || i + a[i] >= n) continue;
    dp[i] = c[n - 1 - i][a[i]];
    for (int j = i + a[i] + 1; j < n; j++) {
      dp[i] += (1LL * dp[j] * c[j - i - 1][a[i]]) % mod;
      if (dp[i] >= mod) dp[i] -= mod;
    }
    ans += dp[i];
    if (ans >= mod) ans -= mod;
  }
  cout << ans << "\n";
  return 0;
}
