func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long MOD = 998244353;   long long inv[5050 + 10], fac[5050 + 10], ifac[5050 + 10];   void setComb() {     inv[0] = 1;     inv[1] = 1;     fac[1] = 1;     ifac[1] = 1;     fac[0] = 1;     ifac[0] = 1;     for (int i = 2; i < 5050; i++) {       inv[i] = (-MOD / i) * inv[MOD % i] % MOD;       fac[i] = fac[i - 1] * i % MOD;       ifac[i] = ifac[i - 1] * inv[i] % MOD;       inv[i] = (inv[i] + MOD) % MOD;       fac[i] = (fac[i] + MOD) % MOD;       ifac[i] = (ifac[i] + MOD) % MOD;     }     return;   }   long long comb(long long n, long long k) {     if (n < k || n < 0 || k < 0)       return 0;     else       return ((fac[n] * ifac[k] % MOD * ifac[n - k] % MOD + MOD) % MOD);   }   long long hcomb(long long n, long long r) {     if (n == 0 && r == 0)       return 1;     else if (n < 0 || r < 0)       return 0;     else       return comb(n + r - 1, r - 1);   }   int N;   vector<int> A;   long long dp[5050][5050];   long long cnt[5050];   void add(long long &a, long long b) { a = (a + b) % MOD; }   void mul(long long &a, long long b) { a = a * b % MOD; }   int main() {     cin.tie(0);     ios::sync_with_stdio(false);     cin >> N;     A.resize(N);     for (int i = 0; i < (N); ++i) cin >> A[i];     sort(A.begin(), A.end());     for (int i = 0; i < (N); ++i) cnt[A[i]]++;     setComb();     dp[0][0] = 1;     for (int i = 0; i < N; i++) {       long long sum = 0;       for (int j = 0; j <= 5000; j++) {         long long res = sum;         mul(res, cnt[j]);         mul(res, inv[N - i]);         add(dp[i + 1][j], res);         sum += dp[i][j];       }     }     long long ans = 0;     for (int i = 1; i < N; i++) {       for (int j = 0; j <= 5000; j++) {         long long res = dp[i][j];         mul(res, cnt[j] - 1);         mul(res, inv[N - i]);         add(ans, res);       }     }     cout << ans << endl;     return 0;   }   