#include <bits/stdc++.h>
using namespace std;
const long long int mod = 998244353;
const long long int inf = 1e18;
const long long int N = 1e3 + 5;
long long int n;
long long int a[N];
long long int dp[N][N];
long long int solve(long long int idx, long long int cnt) {
  if (idx == n + 1) {
    return cnt == 0;
  }
  long long int &ans = dp[idx][cnt];
  if (ans != -1) {
    return ans;
  }
  ans = 0;
  if (cnt > 0) {
    ans += solve(idx + 1, cnt - 1);
    ans += solve(idx + 1, cnt);
    ans %= mod;
  } else {
    ans += solve(idx + 1, cnt);
    if (a[idx] >= 1 and a[idx] <= n) ans += solve(idx + 1, a[idx]);
    ans %= mod;
  }
  return ans;
}
void HyperBeast() {
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  memset(dp, -1, sizeof(dp));
  long long int ans = solve(1, 0);
  cout << (ans - 1 + mod) % mod;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) {
    HyperBeast();
    cout << '\n';
  }
}
