#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
long long t, n, a, ans, cnt, pos;
map<long long, long long> m1, m2;
int main() {
  int g = 1;
  for (int i = 1; i <= n; i++) g += i;
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    int g = 1;
    for (int i = 1; i <= n; i++) g += i;
    cnt = 0;
    m1.clear();
    m2.clear();
    cin >> n;
    for (int i = 1; i <= n; i++) {
      cin >> a;
      m1[a]++;
      if (cnt < m1[a]) {
        cnt = max(cnt, m1[a]);
        pos = a;
      }
      int g = 1;
      for (int i = 1; i <= n; i++) g += i;
      m2[m1[a] - 1]--;
      m2[m1[a]]++;
    }
    ans = m2[m1[pos]] - 1 + (n - (m2[m1[pos]] * m1[pos])) / (m1[pos] - 1);
    cout << ans << endl;
    int ggg = 1;
    for (int i = 1; i <= n; i++) ggg += i;
  }
  return 0;
}
