#include <bits/stdc++.h>
using namespace std;
long long t, n, c[2000005];
struct pp {
  long long data, num;
} p[2000005];
int main() {
  cin >> t;
  for (int k = 1; k <= t; k++) {
    scanf("%lld", &n);
    for (int i = 0; i < n; i++) {
      scanf("%lld", &c[i]);
      p[i].data = 0;
      p[i].num = 0;
    }
    sort(c, c + n);
    long long cnt = 0;
    long long maxn = 0x3f3f3f3f3f3f3f3f;
    for (int i = 0; i < n; i++) {
      if (i == 0) {
        p[cnt].data = c[i];
        p[cnt].num++;
      } else if (p[cnt].data == c[i])
        p[cnt].num++;
      else {
        maxn = min(maxn, p[cnt].num);
        cnt++;
        p[cnt].data = c[i];
        p[cnt].num++;
      }
    }
    maxn = 0x3f3f3f3f3f3f3f3f;
    for (int i = 0; i <= cnt; i++) maxn = min(maxn, p[i].num);
    maxn++;
    for (int i = 0; i <= cnt; i++) {
      int x = (p[i].num - 1) / maxn + 1;
      while (p[i].num < (maxn - 1) * x || p[i].num > maxn * x) {
        maxn--;
        x = (p[i].num - 1) / maxn + 1;
      }
    }
    long long num = 0;
    long long ans = 0x3f3f3f3f3f3f3f3f;
    for (int i = 1; i <= maxn; i++) {
      num = 0;
      bool flag = false;
      for (int j = 0; j <= cnt; j++) {
        int x = (p[j].num - 1) / i + 1;
        if (p[j].num < (i - 1) * x || p[j].num > i * x) {
          flag = true;
          break;
        }
        num += x;
      }
      if (flag) continue;
      ans = min(ans, num);
    }
    printf("%lld", ans);
    if (k != t) printf("\n");
  }
}
