#include <bits/stdc++.h>
#include <atcoder/all>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using namespace atcoder;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = (ll)a;i < (ll)b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = (ll)b-1LL;i >= (ll)a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<ld,ld> pdd;

pll operator+(pll a,pll b){
  return pll(a.first+b.first,a.second+b.second);
}
pll operator-(pll a,pll b){
  return pll(a.first-b.first,a.second-b.second);
}
pll operator*(ll a,pll b){
  return pll(b.first*a,b.second*a);
}
const ll INF=(1LL<<60);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  a=abs(a);
  b=abs(b);
  if(a==0)return b;
  if(b==0)return a;
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif
template<class T>
bool chmax(T& a,const T& b){
  if(a<b){
    a=b;
    return true;
  }
  return false;
}
template<class T>
bool chmin(T& a,const T& b){
  if(a>b){
    a=b;
    return true;
  }
  return false;
}
template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}

const long long MOD = 998244353;
const long long max_cache=1000000;
long long cache_ffact[max_cache],cache_fact[max_cache],cache_inv_fact[max_cache];
long long combination_cached(long long n,long long r){
  ll m=MOD;
  static bool cached=false;
  if(cached==false){
    cached=true;
    cache_inv_fact[1]=1;
    for (long long i = 2; i < max_cache; i++) {
      cache_inv_fact[i]=(m-m/i)*cache_inv_fact[m%i]%m;
    }
    for (long long i = 2; i < max_cache; i++){
      cache_inv_fact[i]=cache_inv_fact[i]*cache_inv_fact[i-1]%m;
    }
    cache_fact[0]=1;
    for (long long i = 1; i < max_cache; i++) {
      cache_fact[i]=cache_fact[i-1]*i%m;
    }
    cache_ffact[0]=cache_ffact[1]=1;
    for (ll i=2;i < max_cache; i++){
      cache_ffact[i]=cache_ffact[i-2]*i%m;
    }
  }
  if(r<0||r>n)return 0;
  if(r==0||r==n)return 1;
  if(n>m){
    std::cerr<<"Combination Error: n is greater than m"<<std::endl;
    exit(1);
  }
  r=min(r,n-r);
  return cache_fact[n]*cache_inv_fact[r]%m*cache_inv_fact[n-r]%m;
}

void solve(long long N, std::vector<long long> h){
      cout<<0<<endl;
      return;
  combination_cached(1,1);
  vector<ll> mp(100000);
  REP(2*N){
    mp[h[i]]++;
  }
  vector<ll> st;
  REP(100000){
    if(mp[i]>N){
    }
    if(mp[i]>1){
      st.push_back(mp[i]);
    }
  }
  deque<vector<ll>> dp;
  for (auto &&i : st)
  {
    vector<ll> tmp{1};
    FOR(j,1,i/2+1){
      tmp.push_back(combination_cached(i,2*j)*cache_ffact[2*j-1]%MOD);
    }
    dp.push_back(move(tmp));
  }
  while(dp.size()>1){
    dp.push_back(convolution(move(dp[0]),move(dp[1])));
    dp.pop_front();dp.pop_front();
  }
  {
    vector<ll> dp2=move(dp[0]);
    vector<ll> dp=move(dp2);
    ll ans=0;
    REP(dp.size()){
      if(i%2==0){
        ans=(ans+dp[i]*cache_ffact[max(0LL,2*(N-i)-1)]%MOD)%MOD;
      }else{
        ans=(ans+MOD-dp[i]*cache_ffact[max(0LL,2*(N-i)-1)]%MOD)%MOD;
      }
    }
    ans=(ans%MOD)+MOD;
    ans%=MOD;
    cout<<ans<<endl;

  }
}

int main(){
  cout<<setprecision(1000);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> h(2*N);
    for(int i = 0 ; i < 2*N ; i++){
        scanf("%lld",&h[i]);
    }
    solve(N, std::move(h));
    return 0;
}
