#include <atcoder/convolution>
#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
#define INF_LL 1000000000000000000LL
#define INF 200000000
#define MOD 998244353
#define ll long long
#define all(x) x.begin(), x.end()
#define REP(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)
// typedef float double;
// typedef priority_queue prique;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<ll> vl;
typedef vector<vi> matrix;
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int sign[2] = {1, -1};
template <class T> bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll modpow(ll a, ll b, ll m) {
    if(b == 0)
        return 1;
    ll t = modpow(a, b / 2, m);
    if(b & 1) {
        return (t * t % m) * a % m;
    } else {
        return t * t % m;
    }
}

struct edge {
    int to;
    ll cost;
    edge(int t, ll c) { to = t, cost = c; }
};

using mint = modint998244353;

mint fac[100002];
mint dfac[100002];

mint comb(int n, int r) { return fac[n] / (fac[n - r] * fac[r]); }

int main() {
    fac[0] = 1;
    dfac[0] = 1;
    dfac[1] = 1;
    rep(i, 100001) {
        fac[i + 1] = fac[i] * (i + 1);
        dfac[i + 2] = dfac[i] * (i + 2);
    }
    int n;
    cin >> n;
    vector<int> a(100000, 0);
    rep(i, 2 * n) {
        int h;
        cin >> h;
        a[h - 1]++;
    }
    vector<vector<mint>> p(100000);
    rep(i, 100000) {
        p[i].push_back(1);
        for(int k = 2; k <= a[i]; k += 2) {
            p[i].push_back(comb(a[i], k) * dfac[k - 1]);
        }
    }
    sort(all(p), [](auto x, auto y) { return x.size() < y.size(); });
    vector<mint> dp = {1};
    rep(i, 100000) { dp = convolution(dp, p[i]); }
    mint ans = 0;
    rep(i, dp.size()) {
        // cout << dp[i].val() << endl;
        if(i & 1) {
            ans -= dp[i] * dfac[max(0, 2 * (n - i) - 1)];
        } else {
            ans += dp[i] * dfac[max(0, 2 * (n - i) - 1)];
        }
    }
    cout << ans.val() << endl;
    return 0;
}
