#include <bits/stdc++.h>
using namespace std;
int c[2000005], t, n;
vector<int> g;
int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -w;
    ch = getchar();
  }
  while (ch <= '9' && ch >= '0') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
int main() {
  t = read();
  while (t--) {
    memset(c, 0, sizeof(c));
    n = read();
    g.clear();
    for (int i = 1; i <= n; i++) {
      int a = read();
      c[a]++;
    }
    int mi = 0x3f3f3f3f;
    for (int i = 1; i <= n; i++)
      if (c[i]) {
        g.push_back(c[i]);
        mi = min(mi, c[i]);
      }
    int ans;
    for (int i = mi + 1; i > 1; i--) {
      ans = 0;
      bool f = 0;
      for (int j = 0; j < g.size(); j++) {
        int x = (g[j] - 1) / i + 1;
        if (x * (i - 1) <= g[j])
          ans += x;
        else {
          f = 1;
          break;
        }
      }
      if (!f) break;
    }
    printf("%d\n", ans);
  }
  return 0;
}
