#include <bits/stdc++.h>
using namespace std;
const int N = 5000 + 5, M = 2e4, mod = 998244353;
vector<int> a;
int inv[N], dp[N][N];
int mul(int a, int b) { return 1ll * a * b % mod; }
int add(int a, int b) { return (a + b) % mod; }
int fp(int b, int p) {
  if (p == 0) return 1;
  long long ret = fp(b, p >> 1);
  ret = ret * ret % mod;
  if (p & 1) ret = ret * b % mod;
  return ret;
}
int solve(int idx, int turn) {
  if (idx == (int)a.size()) return 0;
  if (dp[idx][turn] != -1) return dp[idx][turn];
  int op1 = solve(idx + 1, turn);
  int op2 = mul(mul(a[idx], inv[turn]), solve(idx + 1, turn - 1));
  int op3 = 0;
  if (a[idx] > 1) {
    op3 = mul(a[idx] * (a[idx] - 1), mul(inv[turn], inv[turn - 1]));
  }
  return dp[idx][turn] = add(op1, add(op2, op3));
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int c = 1, idx = 1;
  while (idx < n) {
    if (v[idx] == v[idx - 1])
      c++;
    else {
      a.push_back(c);
      c = 1;
    }
    idx++;
  }
  a.push_back(c);
  for (int i = 1; i <= n; i++) inv[i] = fp(i, mod - 2);
  memset(dp, -1, sizeof dp);
  cout << solve(0, n);
  return 0;
}
