#include <bits/stdc++.h>
const int maxn = 2e6 + 1;
int c[maxn];
void solve() {
  int n, x, res;
  bool f;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) c[i] = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d", &x);
    c[x]++;
  }
  x = 0;
  for (int i = 1; i <= n; i++) {
    if (c[i]) c[x++] = c[i];
    c[i] = 0;
  }
  res = n;
  n = x;
  x = 0;
  for (int i = 1; i < n; i++)
    if (c[i] < c[x]) x = i;
  for (int i = c[x] + 1; i >= 2; i--) {
    f = true;
    x = 0;
    for (int j = 0; j < n; j++) {
      if (c[j] % i == 0 || (c[j] / i + 1) >= i - c[j] % i)
        x += (c[j] + i - 1) / i;
      else {
        f = false;
        break;
      }
    }
    if (f && x < res) res = x;
  }
  printf("%d\n", res);
}
int main() {
  int n;
  scanf("%d", &n);
  while (n--) solve();
  return 0;
}
