#include <bits/stdc++.h>
using namespace std;
bool func(int mid, vector<int> &v, int n) {
  int t = 1;
  for (int i = 1; i < v.size(); i++) {
    if (v[i] == v[i - 1])
      t++;
    else
      break;
  }
  long long k = ((long long)v[0] - 1) * (mid + 1) + t;
  if (k <= n)
    return 1;
  else
    return 0;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> v(n + 1, 0);
    for (int i = 0; i < n; i++) {
      int p;
      cin >> p;
      v[p]++;
    }
    vector<int> s;
    for (int i = 0; i < v.size(); i++) {
      if (v[i] != 0) s.push_back(v[i]);
    }
    sort(s.begin(), s.end());
    reverse(s.begin(), s.end());
    int beg = 0;
    int end = n - 2;
    int mid;
    int ans = 0;
    while (beg <= end) {
      mid = (beg + end) / 2;
      if (func(mid, s, n)) {
        ans = max(ans, mid);
        beg = mid + 1;
      } else
        end = mid - 1;
    }
    cout << ans << endl;
  }
  return 0;
}
