#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 5;
int a[maxn];
vector<int> b;
int main() {
  int t;
  scanf("%d", &t);
  int n;
  int x;
  int x1, x2;
  long long ans;
  long long num;
  int l;
  while (t--) {
    scanf("%d", &n);
    memset(a, 0, sizeof a);
    b.clear();
    for (int i = 0; i < n; i++) {
      scanf("%d", &x);
      a[x]++;
    }
    for (int i = 1; i <= n; i++) {
      if (a[i]) b.push_back(a[i]);
    }
    sort(b.begin(), b.end());
    ans = 1e9 + 5;
    l = b.size();
    for (int i = 2; i <= b[0] + 1; i++) {
      num = 0;
      for (int j = 0; j < l; j++) {
        x1 = (b[j] + i - 1) / i;
        x2 = b[j] / (i - 1);
        if (x1 <= x2)
          num += x1;
        else
          num = 1e9;
      }
      ans = min(ans, num);
    }
    printf("%d\n", ans);
  }
  return 0;
}
