#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
bool f(const int n, const vector<int>& b, const int m) {
  if (b[0] > n / m + 1) return false;
  if (n % m == 0 && b[0] > n / m) return false;
  int z = m;
  int x = n / m;
  int y = 0;
  int w = n % m;
  for (int a : b) {
    if (w > 0 && z - 1 == w) {
      y++;
      w = 0;
    }
    if (z == 1) {
      y = 0;
    }
    if (a > x + y + 1 || (w == 0 && a > x + y)) return false;
    if (a == x + y) {
      z--;
      continue;
    }
    if (a == x + y + 1) {
      z--;
      w--;
      continue;
    }
    if (a < x) {
      x -= a;
      y += a;
    } else if (a == x) {
      x += y;
      y = 0;
      z--;
    } else {
      int t = x + y;
      x = t - (a - x);
      y = t - x;
      z--;
    }
  }
  return true;
}
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b;
  for (int i = 0; i < n; i++) cin >> a[i];
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    int j = i;
    while (j + 1 < n && a[j + 1] == a[i]) j++;
    b.push_back(j - i + 1);
    i = j;
  }
  sort(b.begin(), b.end(), greater<int>());
  int ok = 1, ng = n + 1;
  while (ok + 1 < ng) {
    int m = (ok + ng) / 2;
    if (f(n, b, m))
      ok = m;
    else
      ng = m;
  }
  cout << ok - 1 << endl;
}
int main(void) {
  int t;
  cin >> t;
  while (t--) solve();
}
