#include <bits/stdc++.h>
using namespace std;
int solve() {
  int n;
  cin >> n;
  map<int, int> cnt;
  for (int j = 0; j < n; j++) {
    int c;
    cin >> c;
    cnt[c]++;
  }
  vector<int> v;
  for (auto it = cnt.begin(); it != cnt.end(); it++) {
    v.push_back(it->second);
  }
  sort(v.begin(), v.end());
  n = v.size();
  int mn = v[0];
  long long int ans = 1000000000000;
  for (int j = 1; j <= mn + 1; j++) {
    int d = j;
    long long int cost = 0;
    bool chk = true;
    for (int i = 0; i < n; i++) {
      int a = v[i];
      if ((a / d + 1) >= (d - a % d) || (a % d == 0)) {
        if (a % d == 0) {
          cost += a / d;
        } else {
          cost += a / d + 1;
        }
      } else {
        chk = false;
        break;
      }
    }
    if (chk) {
      ans = min(ans, cost);
    }
  }
  cout << ans << "\n";
  return 0;
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
