#include #include #include #include #include #include #include #include #include #include using namespace std; #define PAIR pair #define MOD 998244353 const int MAX = 1000000; long long fac[MAX], finv[MAX], inv[MAX]; void COMinit(long long mod) { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; for (int i = 2; i < MAX; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = mod - inv[mod % i] * (mod / i) % mod; finv[i] = finv[i - 1] * inv[i] % mod; } } long long COM(long long n, long long k, long long mod) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % mod) % mod; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } long long modinv(long long a, long long mod) { long long b = mod, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= mod; if (u < 0) u += mod; return u; } int main() { COMinit(MOD); long long N; cin >> N; vector A(N); for (int i = 0; i < N; i++) cin >> A[i]; sort(A.begin(), A.end()); vector B; for (int i = 0; i < N; i++) { if (i == 0) B.emplace_back(A[i], 1); else { if (B[B.size() - 1].first == A[i]) B[B.size() - 1].second++; else B.emplace_back(A[i], 1); } } long long n = B.size(); long long sum = 0; for (long long i = 0; i < n; i++) { long long Q = 1; for (long long j = 0; j < n; j++) { if (i == j) continue; Q = Q * modpow(((B[j].first * B[j].first - B[i].first * B[i].first) % MOD + MOD) % MOD, B[j].second, MOD) % MOD; } vector g(B[i].second, 0); g[0] = -1; for (long long j = 0; j < n; j++) { if (i == j) continue; for (long long k = 0; k < B[j].second; k++) { vector g_(B[i].second, 0); for (long long l = 0; l < B[i].second; l++) { if (l == 0) g_[l] = g[l] * ((B[j].first * B[j].first - B[i].first * B[i].first) % MOD + MOD) % MOD; else g_[l] = (g[l] * ((B[j].first * B[j].first - B[i].first * B[i].first) % MOD + MOD) % MOD + g[l - 1]) % MOD; } g = g_; } } g[0] = 0; vector g_(B[i].second, 0); g_[0] = 1; long long Q_pow = 1; for (long long j = 0; j < B[i].second; j++) { if (j != 0) { vector g_2(B[i].second, 0); for (long long k = 0; k < B[i].second; k++) { for (long long l = 0; l < B[i].second; l++) { if (k + l >= B[i].second) continue; g_2[k + l] = (g_2[k + l] + g[k] * g_[l]) % MOD; } } g_ = g_2; } Q_pow = (Q_pow * Q) % MOD; sum += ((g_[j] * modinv(Q_pow, MOD) % MOD) * COM(2 * B[i].second - 2 * j - 2, B[i].second - j - 1, MOD) % MOD) * modinv(modpow(2 * B[i].first, 2 * B[i].second - 2 * j - 1, MOD), MOD) * 2 % MOD; } } cout << (sum % MOD + MOD) % MOD << endl; }