#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5000;
const long long MOD = 998244353;
int X[MAXN + 1], A[MAXN], B[MAXN];
long long F[MAXN][MAXN], lastSum[MAXN], invList[MAXN + 1];
int inv(int, int);
int main() {
  int N;
  cin >> N;
  memset(X, 0, sizeof(X));
  for (int i = 0; i < N; ++i) {
    int x;
    cin >> x;
    ++X[x];
  }
  int M = 0;
  for (int i = 0; i <= N; ++i) {
    if (X[i] > 0) {
      A[M] = i;
      B[M] = X[i];
      ++M;
    }
  }
  for (int i = 1; i <= N; ++i) {
    invList[i] = inv(i, MOD);
  }
  for (int j = 0; j < M; ++j) {
    F[0][j] = B[j] * invList[N] % MOD;
  }
  for (int i = 1; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      lastSum[j] = ((j > 0 ? lastSum[j - 1] : 0) + F[i - 1][j]) % MOD;
    }
    for (int j = 0; j < M; ++j) {
      F[i][j] =
          (j > 0 ? lastSum[j - 1] : 0) * (B[j] * invList[N - i] % MOD) % MOD;
    }
  }
  long long ans = 0;
  for (int i = 1; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      ans += F[i - 1][j] * ((B[j] - 1) * invList[N - i] % MOD) % MOD;
      if (ans >= MOD) {
        ans -= MOD;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
void exEuclid(int a, int b, long long &d, long long &x, long long &y) {
  if (b == 0) {
    d = a;
    x = 1;
    y = 0;
  } else {
    exEuclid(b, a % b, d, y, x);
    y -= (a / b) * x;
  }
}
int inv(int x, int p) {
  long long d, X, Y;
  exEuclid(x, p, d, X, Y);
  return (X % p + p) % p;
}
