#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <atcoder/convolution>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long ll;
typedef long double ld;
using namespace std;

inline ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  while(b>0){
    if(b&1) ret = (ret*num)%p;
    num = (num*num)%p;
    b /= 2;
  }
  return ret;
}

#define Q 998244353
#define N_MAX 1000000
ll fac[N_MAX+1], inv[N_MAX+1], finv[N_MAX+1];
ll comb(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (((fac[n]*finv[n-k])%Q)*finv[k])%Q;
}
ll perm(ll n, ll k){
  if(n<0||k<0||n<k) return 0;
  return (fac[n]*finv[n-k])%Q;
}
void init(){
  fac[0] = finv[0] = fac[1] = finv[1] = inv[1] = 1;
  for(int i = 2; i <= N_MAX; i++){
    fac[i] = (fac[i-1]*i)%Q;
    inv[i] = ((-(Q/i)*inv[Q%i])%Q+Q)%Q;
    finv[i] = (finv[i-1]*inv[i])%Q;
  }
}
ll pp(ll a, ll b){ return (a * b)%Q;}

using namespace atcoder;

typedef vector<ll> fps;
int main(){
  init();
  ll n;std::cin >> n;
  vll cnt(500000, 0);
  for(int i=0;i<2*n;i++){
    ll a;scanf("%lld", &a);
    cnt[a]++;
  }

  multimap<int, fps> mp;

  auto binom = [&](ll l, ll r){
    return (((fac[l] * finv[r])%Q) * finv[l-r])%Q;
  };

  vll dfc(n+1, 1);
  for(ll i=0;i<n;i++) dfc[i+1] = (dfc[i] * (2*i+1))%Q;

  //fps t{1};
  for(int i=0;i<500000;i++){
    if(cnt[i]==0) continue;
    fps tmp(cnt[i]/2+1);
    for(ll j=0;j<=cnt[i]/2;j++){
      ll ret = (dfc[0] * binom(cnt[i], 2*j))%Q;
      tmp[j] = ret;
    }
    mp.emplace(tmp.size(), tmp);
  }

  mp.emplace(1, fps{1});
  while(mp.size()>1){
    auto L = *mp.begin();
    mp.erase(mp.begin());
    auto R = *mp.begin();
    mp.erase(mp.begin());
    auto mg = convolution(L.second, R.second);
    mp.emplace(mg.size(), mg);
  }

  fps ans = (*mp.begin()).second;

  ll A = 0;
  for(ll i=0;i<ans.size();i++){
    if(ans[i]==0) continue;
    ll x = dfc[n-i];
    if(i%2) A = (A + Q - ((ans[i]*x)%Q))%Q;
    else A = (A + (ans[i]*x)%Q)%Q;
    assert(A>=0&&A<Q);
  }

  std::cout << A << '\n';
}

