#include <bits/stdc++.h>
using namespace std;
void jabru() {
  int n;
  cin >> n;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    m[x]++;
  }
  vector<pair<int, int> > fre;
  for (auto x : m) {
    fre.push_back(make_pair(x.second, x.first));
  }
  sort(fre.rbegin(), fre.rend());
  if (fre.size() == 1) {
    cout << 0 << "\n";
    return;
  }
  long long mx = fre[0].first - 1;
  int l = 0, r = n - 1;
  while (r - l > 1) {
    int mid = (r + l) / 2;
    long long got = 0;
    long long tem = 0;
    for (int i = 1; i < fre.size(); i++) {
      if (fre[i].first >= mx)
        tem++;
      else {
        got += fre[i].first;
        if (got >= mx) {
          got -= mx;
          tem++;
        }
      }
    }
    if (tem >= mid) {
      l = mid;
    } else {
      r = mid;
    }
  }
  cout << l << "\n";
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long t;
  t = 1;
  cin >> t;
  long long ss = 1;
  while (t--) {
    ss++;
    jabru();
  }
  return 0;
}
