#include <bits/stdc++.h>
using namespace std;
using pi = pair<long long, long long>;
using vb = vector<bool>;
using vi = vector<long long>;
using vp = vector<pi>;
using vvi = vector<vector<long long>>;
using si = set<long long>;
using mi = map<long long, long long>;
const char nl = '\n';
template <typename... Args>
void rd(Args&... args) {
  ((cin >> args), ...);
}
template <typename T>
void read(T& v) {
  for (auto& x : v) cin >> x;
}
void wt() { cout << endl; }
template <typename Head, typename... Tail>
void wt(Head H, Tail... T) {
  cout << H << ' ';
  wt(T...);
}
template <class T>
bool uin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool uax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
vi a;
long long n;
long long check(long long x) {
  long long s = 0;
  for (auto& v : a) {
    long long q = (v + x - 1) / x;
    if (v < q * (x - 1)) return 1e12;
    s += q;
    ;
  }
  return s;
}
void solve() {
  rd(n);
  vi c(n);
  read(c);
  mi cnt;
  for (auto& x : c) cnt[x]++;
  a.clear();
  for (auto [k, v] : cnt) a.push_back(v);
  long long ans = accumulate((a).begin(), (a).end(), 0ll);
  long long hi = *min_element((a).begin(), (a).end()) + 1;
  ;
  for (long long i = 2; i <= hi; i++) {
    uin(ans, check(i));
  }
  wt(ans);
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long T;
  cin >> T;
  while (T--) solve();
  return 0;
}
