#include <bits/stdc++.h>
using namespace std;
inline int gi() {
  char c;
  int x = 0, f = 1;
  for (; c < '0' || c > '9'; c = getchar())
    if (c == '-') f = -1;
  for (; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + c - '0';
  return x * f;
}
const int N = 5005, Mod = 998244353;
int f[N][N], inv[N], num[N], a[N], n, m, ans;
int main() {
  n = m = gi();
  for (int i = 1; i <= n; ++i) a[i] = gi(), ++num[a[i]];
  inv[0] = inv[1] = 1;
  for (int i = 2; i <= n; ++i)
    inv[i] = 1ll * (Mod - Mod / i) * inv[Mod % i] % Mod;
  sort(a + 1, a + 1 + n);
  n = unique(a + 1, a + 1 + n) - a - 1;
  f[0][0] = 1;
  for (int i = 1; i <= n; ++i)
    for (int j = 0; j <= i; ++j) {
      f[i][j] = 1ll * num[a[i]] * inv[m - j + 1] % Mod * f[i - 1][j - 1] % Mod;
      ans = (ans + 1ll * (num[a[i]] - 1) * inv[m - j] % Mod * f[i][j] % Mod) %
            Mod;
      f[i][j] = (f[i][j] + f[i - 1][j]) % Mod;
    }
  printf("%d", ans);
}
