#include <bits/stdc++.h>
using namespace std;
const long long int Maxn3 = 1e3 + 10;
const long long int Maxn4 = 1e4 + 10;
const long long int Maxn5 = 1e5 + 10;
const long long int Maxn6 = 1e6 + 10;
const long long int Maxn7 = 1e7 + 10;
const long long int Maxn8 = 1e8 + 10;
const long long int Maxn9 = 1e9 + 10;
const long long int Maxn18 = 1e18 + 10;
const long long int Mod1 = 1e7 + 7;
const long long int Mod2 = 1e9 + 7;
const long long int LLMax = LLONG_MAX;
const long long int LLMin = LLONG_MIN;
const long long int INTMax = INT_MAX;
const long long int INTMin = INT_MIN;
long long int mn = LLMax, mx = LLMin;
long long int dp[Maxn3], tmp[Maxn3];
int main() {
  long long int n, mod = 998244353;
  cin >> n;
  dp[0] = 1;
  for (long long int i = 0; i < n; i++) {
    long long int d;
    cin >> d;
    memcpy(tmp, dp, sizeof(dp));
    if (d > 0 and d <= n) tmp[d] = (tmp[d] + dp[0]) % mod;
    for (long long int j = 0; j <= n; j++) tmp[j] = (tmp[j] + dp[j + 1]) % mod;
    memcpy(dp, tmp, sizeof(tmp));
  }
  return cout << (dp[0] - 1 + mod) % mod, 0;
}
