#include <bits/stdc++.h>
using namespace std;
constexpr int tax = 1e4, nax = 2e6, inf = 1e9;
int t, n, tab[nax + 1], ilo[nax + 1], arr[nax + 1];
int check(const int a, const int b) {
  for (int c = 1; c * b <= a; ++c)
    if (a - c * b <= c) return c;
  return 0;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; ++i) {
      int v;
      cin >> v;
      ++tab[v];
    }
    int cnt = 0;
    for (int i = 1; i <= n; ++i)
      if (tab[i]) ++cnt;
    for (int i = 1; i <= n; ++i)
      if (tab[i])
        for (int j = 1; j <= tab[i]; ++j)
          if (check(tab[i], j)) ++ilo[j], arr[j] += check(tab[i], j);
    int res = inf;
    for (int i = 1; i <= n; ++i)
      if (ilo[i] == cnt) res = min(res, arr[i]);
    cout << res << '\n';
    for (int i = 1; i <= n; ++i) tab[i] = ilo[i] = arr[i] = 0;
  }
}
