#include<bits/stdc++.h>
#include<atcoder/convolution>
using namespace atcoder;
using namespace std;
typedef long long ll;
const int MOD = 998244353;
typedef decay<decltype(MOD)>::type T;
struct mi {
    T val;
    explicit operator T() const { return val; }
    mi() { val = 0; }
    mi(const long long& v) {
        val = (-MOD <= v && v <= MOD) ? v : v % MOD;
        if (val < 0) val += MOD; }
    friend ostream& operator<<(ostream& os, const mi& a) { return os << a.val; }
    friend bool operator==(const mi& a, const mi& b) { return a.val == b.val; }
    friend bool operator!=(const mi& a, const mi& b) { return !(a == b); }
    friend bool operator<(const mi& a, const mi& b) { return a.val < b.val; }
    mi operator-() const { return mi(-val); }
    mi& operator+=(const mi& m) {
        if ((val += m.val) >= MOD) val -= MOD;
        return *this; }
    mi& operator-=(const mi& m) {
        if ((val -= m.val) < 0) val += MOD;
        return *this; }
    mi& operator*=(const mi& m) { val = (long long) val * m.val % MOD;
        return *this; }
    friend mi pow(mi a, long long p) {
        mi ans = 1; assert(p >= 0);
        for (; p; p /= 2, a *= a) if (p & 1) ans *= a;
        return ans; }
    friend mi inv(const mi& a) { assert(a != 0); return pow(a, MOD - 2); }
    mi& operator/=(const mi& m) { return (*this) *= inv(m); }
    friend mi operator+(mi a, const mi& b) { return a += b; }
    friend mi operator-(mi a, const mi& b) { return a -= b; }
    friend mi operator*(mi a, const mi& b) { return a *= b; }
    friend mi operator/(mi a, const mi& b) { return a /= b; }
};
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> h(2 * n);
    for (int i = 0; i < 2 * n; i++) {
        cin >> h[i];
    }
    n *= 2;
    vector<mi> fact(n + 5);
    vector<mi> ifact(n + 5);
    fact[0] = ifact[0] = 1;
    for (int i = 1; i < n + 5; i++ ) {
        fact[i] = fact[i - 1] * i;
        ifact[i] = ifact[i - 1] / i;
    }
    auto choose = [&](int x, int y) -> mi {
        if (x < y) {
            return 0;
        }
        return fact[x] * ifact[x - y] * ifact[y];
    };
    map<int, int> cnt;
    for (int i = 0; i < n; i++) {
        cnt[h[i]]++;
    }
    vector<ll> res(1);
    res[0] = 1;
    multiset<pair<int, vector<ll>>> poly;
    poly.emplace(1, res);
    for(auto x: cnt){
        int num = x.second;
        if (num == 1) {
            continue;
        }
        vector<ll> use (num / 2 + 1);
        int cur = num;
        mi run = 1;
        for (int i = 0; i <= num / 2; i++) {
            use[i] = (run * ifact[i]).val;
            run *= choose(cur, 2);
            cur -= 2;
        }
        poly.emplace((int) use.size(), use);
    }
    while (poly.size() >= 2) {
        vector<ll> nxt = convolution<MOD>((*poly.begin()).second, (*next(poly.begin())).second);
        poly.erase(poly.begin());
        poly.erase(poly.begin());
        poly.emplace((int) nxt.size(), nxt);
    }
    res = (*poly.begin()).second;
    mi ans = 0;
    vector<mi> group(n + 1);
    mi run = 1;
    for (int i = 0; i <= n; i += 2) {
        group[i] = run * ifact[i / 2];
        run *= choose(i + 2, 2);
    }
    for (int i = 0; i < res.size(); i++) {
        int num = n - 2 * i;
        ans += res[i] * group[num] * (i % 2 == 0 ? 1 : -1);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9840