#include <bits/stdc++.h>
using namespace std;
const long long inf = (1ll << 62) - 1;
const long long mod = 998244353;
const long long N = 2e6 + 5;
using namespace std;
long long bPow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a);
    }
    b >>= 1;
    a = (a * a);
  }
  return res;
}
long long gcd(long long a, long long b) {
  if (a < b) {
    swap(a, b);
  }
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<long long> spf(N, 0ll);
void sieve() {
  for (long long i = 2; i < N; ++i) {
    if (!spf[i]) {
      for (long long j = 1; i * j < N; j++) {
        spf[i * j] = i;
      }
    }
  }
}
vector<long long> fact(N, 0ll);
void factorial() {
  fact[0] = 1, fact[1] = 1;
  for (long long i = 2; i < N; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
}
long long ncr(long long n, long long r) {
  if (r > n) return 0;
  long long ans = fact[n] % mod;
  ans *= bPow(fact[r], mod - 2) % mod;
  ans %= mod;
  ans *= bPow(fact[n - r], mod - 2) % mod;
  ans %= mod;
  return ans;
}
void solve() {
  long long n;
  cin >> n;
  map<long long, long long> cnt;
  for (long long i = 0; i < n; ++i) {
    long long x;
    cin >> x;
    cnt[x]++;
  }
  long long minCt = inf;
  for (auto ct : cnt) minCt = min(minCt, ct.second);
  long long ans = n;
  for (long long i = 2; i <= minCt + 1; ++i) {
    long long cur = 0;
    bool isOk = true;
    for (auto ct : cnt) {
      long long req = (ct.second + i - 1) / i;
      if (req * (i - 1) > ct.second) {
        isOk = false;
        break;
      }
      cur += req;
    }
    if (isOk) ans = min(ans, cur);
  }
  cout << ans << endl;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long tc = 1;
  cin >> tc;
  while (tc--) {
    solve();
  }
  return 0;
}
