#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
const long long mod = 998244353;
long long dp[maxn][maxn], inv[maxn], col[maxn], n, cnt[maxn], s[maxn];
long long fpm(long long a, long long p) {
  long long r = 1, base = a;
  while (p) {
    if (p & 1) r = r * base % mod;
    base = base * base % mod;
    p /= 2;
  }
  return r;
}
void init() {
  for (int i = 1; i <= n; i++) inv[i] = fpm(i, mod - 2);
  for (int i = 1; i <= n; i++) {
    s[i] = s[i - 1] + cnt[i];
  }
}
int main() {
  cin >> n;
  int tp;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &tp);
    cnt[tp]++;
  }
  init();
  for (int i = n; i >= 1; i--) {
    if (cnt[i] == 0) continue;
    for (int j = 1; j <= n; j++) {
      dp[i][j] = (cnt[i] - 1 + col[j + 1]) * inv[n - j] % mod;
      col[j] = (col[j] + cnt[i] * dp[i][j]) % mod;
    }
  }
  long long ans = 0ll;
  for (int i = 1; i <= n; i++) {
    ans = (ans + dp[i][1] * cnt[i]) % mod;
  }
  cout << ans * inv[n] % mod << endl;
}
