#include <bits/stdc++.h>
using namespace std;
int n;
int a[1002];
long long dp[1002], dp1[1002];
int main() {
  cin >> n;
  dp1[0] = 1;
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++) {
    swap(dp, dp1);
    int now = dp[0];
    for (int j = 0; j <= n; j++) dp1[j] = (dp[j] + dp[j + 1]) % 998244353;
    if (a[i] > 0 && a[i] <= n) dp1[a[i]] = (dp1[a[i]] + now) % 998244353;
  }
  cout << (dp1[0] + 998244353 - 1) % 998244353 << endl;
  return 0;
}
