#include <iostream>
#include <vector>
#include <map>
#include <atcoder/convolution>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;
typedef long long ll;

const ll MOD = 998244353;

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

ll calc_div(ll a, ll b) {
    return a * calc_pow(b, MOD - 2) % MOD;
}

vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;
}

ll calc_comb(ll n, ll r) {
    if (n < r)return 0;
    return calc_div(fact[n], fact[r] * fact[n - r] % MOD);
}

int main() {
    init_fact(100000);
    vector<ll> match(50010);
    match[0] = 1;
    for (int i = 1; i < 50010; i++)match[i] = match[i - 1] * (i * 2 - 1) % MOD;

    int n;
    cin >> n;

    map<int, int> ma;
    for (int i = 0; i < n * 2; i++) {
        int h;
        cin >> h;
        ma[h]++;
    }

    vector<int> v;
    for (auto &x:ma)v.emplace_back(x.second);

    vector<ll> dp(n + 1);
    dp[0] = 1;
    int maxPair = 0;
    for (auto &x:v) {
        vector<ll> huga(x / 2 + 1);
        for (int pa = 0; pa <= x / 2; pa++)huga[pa] = calc_comb(x, pa * 2) * match[pa] % MOD;

        vector<ll> after = convolution<998244353>(dp, huga);
        dp = after, maxPair += x / 2;
    }

    for (int i = 0; i <= n; i++)dp[i] *= match[n - i], dp[i] %= MOD;

    ll ret = 0;
    for (int i = 0; i <= n; i++) {
        if (i % 2 == 0) {
            ret += dp[i];
            if (ret >= MOD)ret -= MOD;
        } else {
            ret -= dp[i];
            if (ret < 0)ret += MOD;
        }
    }

    cout << ret << endl;
    return 0;
}