#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
int a[maxn], vis[maxn], num[maxn];
map<int, int> mp;
int cmp(int x, int y) { return x > y; }
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    mp.clear();
    int n;
    scanf("%d", &n);
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      vis[i] = 0;
      num[i] = 0;
      if (!mp[a[i]]) mp[a[i]] = ++cnt;
      a[i] = mp[a[i]];
    }
    for (int i = 1; i <= n; i++) vis[a[i]]++;
    sort(vis + 1, vis + 1 + cnt, cmp);
    int len = vis[1];
    if (cnt == 1) {
      printf("0\n");
      continue;
    }
    int flag = 0;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == len) vis[i]--;
    }
    len--;
    int now = 1;
    for (int i = 1; i <= cnt; i++) {
      int tmp = vis[i];
      while (tmp) {
        tmp--;
        num[now]++;
        now = now + 1;
        if (now == len + 1) now = 1;
      }
    }
    printf("%d\n", num[len] - 1);
  }
  return 0;
}
