#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

#include<atcoder/convolution>
using namespace atcoder;

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int MAX=1000005;
ll F[MAX],FF[MAX];

void Init(){
	F[0]=1;
	FF[0]=1;
	for(int i=1;i<MAX;i++) F[i]=F[i-1]*i%mod;
	for(int i=1;i<MAX;i++) FF[i]=FF[i-1]*(2*i-1)%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

ll nCk(ll n,ll k){
	return Div(F[n],F[n-k]*F[k]%mod);
}

const int M=1000001;
int n,a[M],two[M];

int main(){
	two[0]=1;
	for(int i=1;i<M;i++) two[i]=two[i-1]*2%mod;
	Init();
	cin>>n;
	for(int i=0;i<2*n;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	vvl b;
	for(auto i:a) if(i>1){
		vl c(i/2+1);
		for(int j=0;j<=i/2;j++){
			c[j]=nCk(i,2*j)*FF[j]%mod;
		}
		b.push_back(c);
	}
	while(b.size()>1){
		int m=b.size();
		vvl b_;
		for(int i=0;i<m/2;i++){
			vl c=convolution(b[2*i],b[2*i+1]);
			b_.push_back(c);
		}
		if(m%2==1) b_.push_back(b.back());
		b=b_;
	}
	ll m=b[0].size(),res=0;
	for(int i=0;i<m;i++){
		ll t=b[0][i]*FF[n-i];
		if(i%2==1) (t*=mod-1)%=mod;
		(res+=t)%=mod;
	}
	cout<<res<<endl;
}