#include <bits/stdc++.h>
using namespace std;
template <class T>
ostream& operator<<(ostream& os, vector<T> V) {
  os << "[ ";
  for (auto v : V) os << v << " ";
  return os << "]";
}
template <class T>
ostream& operator<<(ostream& os, set<T> S) {
  os << "{ ";
  for (auto s : S) os << s << " ";
  return os << "}";
}
template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
template <class L, class R>
ostream& operator<<(ostream& os, map<L, R> M) {
  os << "{ ";
  for (auto m : M) os << "(" << m.first << ":" << m.second << ")";
  return os << "}";
}
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
const int mod = 998244353;
const int N = 5e3 + 100;
int dp[2][N][N];
int inv[N];
inline int mul(int a, int b) { return a * 1ll * b % mod; }
inline int add(int a, int b) {
  a += b;
  if (a >= mod) a -= mod;
  return a;
}
int power(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = mul(res, x);
    x = mul(x, x);
    y >>= 1;
  }
  return res;
}
int A[N];
int cnt[N];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(25);
  int n;
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> A[i];
    ++cnt[A[i]];
  }
  for (int i = 1; i < N; ++i) inv[i] = power(i, mod - 2);
  inv[0] = 1;
  assert(inv[0] == 1);
  sort(A + 1, A + n + 1);
  dp[0][0][0] = 1;
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= i; ++j) {
      if (j == 0)
        dp[0][i][0] = 1;
      else {
        if (A[i] == A[i - 1]) {
          ans = add(ans, mul(inv[n - j + 1], dp[1][i - 1][j - 1]));
          dp[0][i][j] = add(dp[0][i][j], dp[0][i - 1][j]);
          dp[1][i][j] =
              add(dp[1][i][j], mul(dp[0][i - 1][j - 1], inv[n - j + 1]));
          dp[1][i][j] = add(dp[1][i][j], dp[1][i - 1][j]);
        } else {
          dp[0][i][j] = add(dp[0][i][j], add(dp[1][i - 1][j], dp[0][i - 1][j]));
          dp[1][i][j] = add(dp[1][i][j],
                            mul(inv[n - j + 1],
                                add(dp[1][i - 1][j - 1], dp[0][i - 1][j - 1])));
        }
      }
    }
  }
  cout << mul(2, ans) << "\n";
  return 0;
}
