#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e8;
long long a[2000005];
vector<long long> id;
vector<long long> num;
int n;
bool judge(long long h) {
  for (auto v : num) {
    if (v - ((h - (v % h)) % h) * (h - 1) < 0) return false;
  }
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long kase;
  cin >> kase;
  for (register long long kas = (1); kas <= (kase); ++kas) {
    for (auto v : id) a[v] = 0;
    id.clear();
    num.clear();
    cin >> n;
    for (register long long i = (1); i <= (n); ++i) {
      long long c;
      cin >> c;
      if (!a[c]) id.push_back(c);
      a[c]++;
    }
    for (auto v : id) num.push_back(a[v]);
    long long big = 0;
    for (auto v : num) big = max(big, v);
    long long r = big + 1;
    while (1) {
      if (judge(r)) break;
      r--;
    }
    long long ans = 0;
    for (auto v : num) {
      long long t = (r - (v % r)) % r;
      ans += t;
      ans += (v - t * (r - 1)) / r;
    }
    cout << ans << '\n';
  }
  return 0;
}
