#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
ll cnt[2000005];
vector<ll> v;
vector<ll> ans[2];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int t, n;
  ll x;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 1; i <= n; i++) cnt[i] = 0;
    for (int i = 1, a; i <= n; i++) cin >> a, cnt[a]++;
    v.clear();
    for (int i = 1; i <= n; i++)
      if (cnt[i]) v.push_back(cnt[i]);
    sort(v.begin(), v.end());
    ans[0].clear();
    for (int i = 1; i <= v[0] + 1; i++) ans[0].push_back(i);
    for (ll x : v) {
      ans[1].clear();
      for (ll i : ans[0]) {
        if (x % i == 0) {
          ans[1].push_back(i);
        } else if ((i - 1) * (i - x % i) <= x) {
          ans[1].push_back(i);
        }
      }
      swap(ans[0], ans[1]);
    }
    ll siz = ans[0][ans[0].size() - 1];
    ll ans = 0;
    for (auto &i : v) {
      while (i % siz != 0) {
        ans++;
        i -= siz - 1;
      }
      ans += (i) / siz;
    }
    cout << ans << '\n';
  }
}
