#include <bits/stdc++.h>
using namespace std;
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % 998244353;
    y = y / 2, x = (x * x) % 998244353;
  }
  return res % 998244353;
}
vector<long long> arr;
long long cnt[5001];
long long n;
long long dp[5001][5001];
long long tle[5001];
long long func(long long index, long long taken) {
  if (index == arr.size()) return 0;
  long long &ret = dp[index][taken];
  if (ret != -1) return ret;
  ret = 0;
  if (cnt[arr[index]] > 1)
    ret = (cnt[arr[index]] * (cnt[arr[index]] - 1)) * tle[n - taken] %
          998244353 * tle[n - taken - 1] % 998244353;
  ret = ret +
        func(index + 1, taken + 1) * (cnt[arr[index]]) % 998244353 *
            tle[n - taken] % 998244353 +
        func(index + 1, taken);
  return ret % 998244353;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  long long i;
  memset(dp, -1, sizeof(dp));
  for (i = 1; i <= n; i++) tle[i] = power(i, 998244353 - 2);
  set<long long> lol;
  for (i = 0; i < n; i++) {
    long long k;
    cin >> k;
    cnt[k]++;
  }
  for (i = 0; i <= n; i++)
    if (cnt[i]) arr.push_back(i);
  cout << func(0, 0);
}
