#include <bits/stdc++.h>
using namespace std;
vector<int> cnt;
int n;
bool simulate(vector<int> &a, int x) {
  if (x == 0) return true;
  for (int i = 1; i <= n; i++) cnt[i] = 0;
  for (int i = 0; i < n; i++) cnt[a[i]]++;
  set<pair<int, int>, greater<pair<int, int>>> s;
  for (int i = 1; i <= n; i++)
    if (cnt[i] > 0) s.insert({cnt[i], i});
  vector<int> b;
  for (int i = 0; i < n; i++) {
    if (i >= x && cnt[b[i - x]]) {
      s.insert({cnt[b[i - x]], b[i - x]});
    }
    if (s.empty()) return false;
    b.push_back(s.begin()->second);
    s.erase(s.begin());
    cnt[b.back()]--;
  }
  return true;
}
void solve() {
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  cnt = vector<int>(n + 1);
  int l = 0, r = n, res = -1;
  while (l <= r) {
    int mid = (l + r) / 2;
    if (simulate(a, mid)) {
      res = mid;
      l = mid + 1;
    } else {
      r = mid - 1;
    }
  }
  cout << res - 1 << "\n";
}
int main() {
  int T;
  cin >> T;
  while (T--) solve();
}
