#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx")
using namespace std;
const long long mod = 998244353;
long long modpow(long long A, long long B) {
  long long kotae = 1;
  while (B > 0) {
    if (B & 1) kotae = kotae * A % mod;
    A = A * A % mod;
    B >>= 1;
  }
  return kotae;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  int D[200000];
  for (int i = 0; i < (N); i++) cin >> D[i];
  sort(D, D + N);
  int saidai = D[N - 1];
  int kazu[200001] = {};
  for (int i = 0; i < (N); i++) kazu[D[i]]++;
  long long kotae = 1;
  if (kazu[0] != 1) {
    cout << (0) << "\n";
    return 0;
  }
  if (saidai > N - 1) {
    cout << (0) << "\n";
    return 0;
  }
  int mae = 1;
  for (int i = 1; i <= (saidai); i++) {
    if (kazu[i] == 0) kotae = 0;
    for (int j = 0; j < (kazu[i]); j++) kotae = kotae * mae % mod;
    mae = kazu[i];
  }
  cout << (kotae) << "\n";
  return 0;
}
