#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;

ll Ep(int x, int y){
  if(y == 1) return x;
  ll r = Ep(x,y/2);
  if(y%2 == 1) return r *r%MOD *x%MOD;
  else return r *r%MOD;
}

int main(){
  int n, x;
  cin >> n;
  cin >> x;
  if(x != 0){
    cout << 0 << endl;
    return 0;
  }
  map<int, int> mp;
  for(int i=1; i<n; ++i){
    cin >> x;
    if(x == 0){
      cout << 0 << endl;
      return 0;
    }
    ++mp[x];
  }
  ll ans = 1;
  for(auto p: mp){
    if(p.first == 1) continue;
    ans *= Ep(mp[p.first-1], p.second);
    ans %= MOD;
  }
  cout << ans << endl;
}
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
int main(){
  int N;
  cin>>N;
  long long D[100000],num[100000];
  int judge=0;
  for(int i=0;i<N;i++){
   cin>>D[i];
   num[i]=0;
  }
  if(D[0]==0){
  sort(D,D+N);
  for(int i=0;i<N;i++){
    if(judge==D[i]) judge++;
    num[D[i]]++;
  }
  if(judge!=D[N-1]+1||num[0]>1) cout<<0<<endl;
  else{
    long long answer=1;
    for(int i=1;i<judge;i++){
      for(int j=0;j<num[i];j++) answer=(answer*num[i-1])%998244353;
    }
    cout<<answer<<endl;
  }
  }
  else cout<<0<<endl;
  
  return 0;
}