#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
using namespace std;
using ll = int64_t;
constexpr int M = 2 * 1000000 + 10;
vector<int> cs;
int cnt[M];
bool processed[M];
int how_much[M];
vector<int> candidates;
vector<int> single_candidates;
bool was[M];
void process(int c) {
  single_candidates.push_back(c + 1);
  single_candidates.push_back(c);
  single_candidates.push_back(1);
  single_candidates.push_back(2);
  for (int s = 1; s <= c; s++) {
    int l = c / s;
    if (l * s == c) single_candidates.push_back(l);
    if ((l + 1) * s >= c) {
      single_candidates.push_back(l + 1);
    }
  }
  for (int candidate : single_candidates) {
    if (!was[candidate]) {
      was[candidate] = true;
      ++how_much[candidate];
      candidates.push_back(candidate);
    }
  }
  for (int candidate : single_candidates) {
    was[candidate] = false;
  }
  single_candidates.clear();
}
void solve() {
  int n;
  cin >> n;
  cs.resize(n);
  for (int i = 0; i < n; i++) {
    cin >> cs[i];
    --cs[i];
    ++cnt[cs[i]];
  }
  int target = 0;
  candidates.clear();
  for (int c : cs) {
    if (!processed[c]) {
      processed[c] = true;
      process(cnt[c]);
      ++target;
    }
  }
  for (int c : cs) {
    processed[c] = false;
  }
  int answer = 1;
  for (int c : candidates) {
    if (how_much[c] == target) {
      answer = max(answer, c);
    }
  }
  int result = 0;
  for (int c : cs) {
    if (!processed[c]) {
      processed[c] = true;
      result += (cnt[c] + answer - 1) / answer;
    }
  }
  cout << result << "\n";
  for (int c : candidates) {
    how_much[c] = 0;
  }
  for (int c : cs) {
    cnt[c] = 0;
    processed[c] = false;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int tests;
  cin >> tests;
  for (int test = 0; test < tests; ++test) solve();
  return 0;
}
