#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 3;
int n, a[N];
void init() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
}
int cnt[N];
void solve() {
  fill_n(cnt, n + 1, 0);
  for (int i = 0; i < n; i++) {
    cnt[a[i]]++;
  }
  vector<int> freq;
  for (int i = 0; i <= n; i++) {
    if (cnt[i]) {
      freq.push_back(cnt[i]);
    }
  }
  sort(freq.begin(), freq.end());
  int pages, spaces, ans;
  bool fail;
  for (int sz = freq[0] + 1; sz > 1; sz--) {
    fail = false;
    ans = 0;
    for (int f : freq) {
      pages = (f + sz - 1) / sz;
      spaces = pages * sz - f;
      if (spaces > pages) {
        fail = true;
        break;
      }
      ans += pages;
    }
    if (fail) continue;
    printf("%d\n", ans);
    return;
  }
  printf("%d\n", n);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    init();
    solve();
  }
  return 0;
}
