#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
ostream &operator<<(ostream &os, const pair<A, B> &p) {
  return os << '(' << p.first << ", " << p.second << ')';
}
template <typename T_container, typename T = typename enable_if<
                                    !is_same<T_container, string>::value,
                                    typename T_container::value_type>::type>
ostream &operator<<(ostream &os, const T_container &v) {
  os << '{';
  string sep;
  for (const T &x : v) os << sep << x, sep = ", ";
  return os << '}';
}
void dbg() { cerr << endl; }
template <typename Head, typename... Tail>
void dbg(Head H, Tail... T) {
  cerr << ' ' << H;
  dbg(T...);
}
template <typename T>
void dbg_a(const T *a, int l, int r) {
  cerr << "{";
  for (int i = l; i < r; i++) cerr << a[i] << ", ";
  cerr << a[r] << "}\n";
}
const long long INF = 0x3f3f3f3f;
const long long N = 2e6 + 5;
const long long mod = 1e9 + 7;
long long n, k;
void solve() {
  cin >> n;
  vector<long long> a(n + 1), c(n + 1), g;
  for (long long i = 1; i <= n; i++) {
    cin >> a[i];
    c[a[i]]++;
  }
  for (long long i = 1; i <= n; i++) {
    if (c[i]) g.emplace_back(i);
  }
  if (g.size() == 0) {
    cout << 0 << "\n";
    return;
  }
  long long p = (long long)(g.size());
  long long lim = n / p + 1;
  long long ans = INF;
  for (long long s = 1; s <= lim; s++) {
    long long sum = 0;
    for (long long i = 0; i < g.size(); i++) {
      long long j = g[i];
      long long x = (c[j] - 1) / s + 1;
      if (s * x < c[j] || (s - 1) * x > c[j]) goto end;
      sum += x;
    }
    ans = min(ans, sum);
  end:
    1;
  }
  cout << ans << "\n";
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long T = 1;
  cin >> T;
  while (T--) solve();
  return 0;
}
