#include <bits/stdc++.h>
using namespace std;
long long f[5050][5050], N, a[5050], inv[5050], s[5050], tmp[5050];
long long read(long long x = 0) {
  long long c, f = 1;
  for (c = getchar(); !isdigit(c); c = getchar())
    if (c == '-') f = -f;
  for (; isdigit(c); c = getchar()) x = x * 10 + c - 48;
  return f * x;
}
void init() {
  long long i;
  inv[1] = 1;
  for (i = 2; i < 5050; i++)
    inv[i] =
        inv[998244353ll % i] * (998244353ll - 998244353ll / i) % 998244353ll;
  N = read();
  for (i = 1; i <= N; i++) tmp[read()]++;
  auto x(0);
  for (i = 1; i <= N; i++)
    if (tmp[i]) a[++x] = tmp[i];
  N = x;
  for (i = 1; i <= N; i++) s[i] = s[i - 1] + a[i];
}
void dp() {
  long long i, j;
  for (i = 0; i < 5050; i++) f[i][0] = 1;
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= i; j++) {
      f[i][j] = f[i - 1][j] +
                f[i - 1][j - 1] * a[i] % 998244353ll * inv[s[N] - j + 1];
      f[i][j] %= 998244353ll;
    }
  }
}
int main() {
  init();
  dp();
  long long i, j, ans(0);
  for (i = 1; i <= N; i++)
    for (j = 0; j <= i - 1; j++) {
      ans += f[i - 1][j] * (a[i] * (a[i] - 1) % 998244353ll) % 998244353ll *
             (inv[s[N] - j] * inv[s[N] - j - 1] % 998244353ll);
      ans %= 998244353ll;
    }
  printf("%lld", ans);
  return 0;
}
