#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
int mul(int a, int b) { return (long long)a * b % mod; }
int add(int a, int b) {
  int res = (long long)a + b;
  if (res < 0)
    res += mod;
  else if (res > mod)
    res -= mod;
  return res;
}
int bpow(int x, int p) {
  int res = 1;
  while (p) {
    if (p & 1) res = mul(res, x);
    p >>= 1;
    if (p) x = mul(x, x);
  }
  return res;
}
int inv(int x) { return bpow(x, mod - 2); }
void solve() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> cnt(n + 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  sort(a.begin(), a.end());
  a.erase(unique(a.begin(), a.end()), a.end());
  int m = n;
  n = a.size();
  vector<int> dp(n);
  for (int i = 0; i < n; i++) {
    dp[i] = mul(cnt[a[i]], inv(m));
  }
  vector<int> inv_p(m + 1);
  for (int i = 1; i <= m; i++) {
    inv_p[i] = inv(i);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    vector<int> dp2(n);
    int sum = 0;
    int sum2 = 0;
    for (int j = i - 1; j < n; j++) {
      int l = sum - i + 1, w = cnt[a[j]] - 1, g = m - sum - cnt[a[j]];
      ans = add(ans, mul(dp[j], mul(w, inv_p[l + w + g])));
      dp2[j] = mul(sum2, cnt[a[j]]);
      sum2 = add(sum2, mul(dp[j], inv_p[l + w + g]));
      sum += cnt[a[j]];
    }
    dp.swap(dp2);
  }
  cout << ans;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q = 1;
  for (; q > 0; q--) {
    solve();
  }
}
