#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 5;
int t, n, num[N], x, ans[N], vis[N];
vector<int> v;
int main() {
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
      scanf("%d", &x);
      num[x]++;
    }
    int minn = N;
    for (int i = 1; i <= n; i++)
      if (num[i] > 0) v.push_back(num[i]);
    for (int i = 0; i < v.size(); i++) {
      minn = min(minn, v[i] + 1);
      for (int j = 1; j <= v[i] + 1; j++) {
        if (v[i] % j == 0 || v[i] + 1 == j ||
            (v[i] + j - 1) / j * j - v[i] <= (v[i] + j - 1) / j) {
          ans[j] += (v[i] + j - 1) / j;
          vis[j]++;
        }
      }
    }
    for (int i = minn; i >= 1; i--) {
      if (vis[i] == v.size()) {
        printf("%d\n", ans[i]);
        assert(i != 1);
        break;
      }
    }
    for (int i = 1; i <= n + 1; i++) num[i] = 0, ans[i] = 0, vis[i] = 0;
    v.clear();
  }
  return 0;
}
