#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 14;
int cnt[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  srand(time(0));
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    fill(cnt, cnt + n, 0);
    for (int i = 0; i < n; i++) {
      int x;
      cin >> x;
      cnt[--x]++;
    }
    vector<int> v;
    for (int i = 0; i < n; i++)
      if (cnt[i]) v.push_back(cnt[i]);
    sort(v.begin(), v.end());
    int s = v[0] + 1;
    v.erase(unique(v.begin(), v.end()), v.end());
    random_shuffle(v.begin(), v.end());
    auto ok = [&v](int s) {
      for (auto x : v)
        if (x % s && x % s < s - (x + s - 1) / s) return 0;
      return 1;
    };
    while (!ok(s)) s--;
    long long ans = 0;
    for (int i = 0; i < n; i++) ans += (cnt[i] + s - 1) / s;
    cout << ans << '\n';
  }
}
