#include <bits/stdc++.h>
using namespace std;
int n;
int sum[2000010];
set<int> a;
int c[2000010];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  if (fopen("a.txt", "r")) {
    freopen("a.txt", "r", stdin);
  }
  int T;
  cin >> T;
  while (T--) {
    cin >> n;
    for (int x : a) c[x] = 0;
    a.clear();
    for (int i = 1; i <= n; i++) sum[i] = 0;
    int num = 0;
    for (int i = 1; i <= n; i++) {
      int x;
      cin >> x;
      c[x]++;
      if (c[x] == 1) num++;
      a.insert(x);
    }
    sum[0] = 0;
    for (int x : a) {
      if (c[x] > 0) sum[c[x]] += 1;
    }
    for (int i = 1; i <= n; i++) sum[i] += sum[i - 1];
    int S = 1;
    for (int s = 2; s <= n; s++) {
      int getSum = 0;
      int R = 0;
      for (int j = 1; (s - 1) * j <= n; j++) {
        int l = max(R + 1, max(1, j * (s - 1)));
        int r = min(n, s * j);
        if (l > r) continue;
        getSum += sum[r] - sum[l - 1];
        R = r;
      }
      if (getSum == num) {
        S = s;
      }
    }
    if (S == 1)
      cout << n << "\n";
    else {
      int ans = 0;
      for (int i : a) {
        if (c[i] % S == 0)
          ans += c[i] / S;
        else
          ans += c[i] / S + 1;
      }
      cout << ans << "\n";
    }
  }
}
