#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O2")
#pragma GCC optimization("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const int N = 2000005;
int n, ara[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    cin >> n;
    map<int, int> mp;
    for (int i = 1; i <= n; i++) cin >> ara[i], mp[ara[i]]++;
    vector<int> vec;
    for (auto x : mp) {
      vec.push_back(x.second);
    }
    sort(vec.begin(), vec.end());
    int mx = vec[0] + 1;
    int ans = 1e9;
    for (int s = 1; s <= mx; s++) {
      bool ok = 1;
      int sum = 0;
      for (int x : vec) {
        int b = (s - (x) % s) % s;
        int a = (x + b) / s - b;
        if (a < 0) {
          ok = 0;
          break;
        }
        sum += a + b;
      }
      if (ok) {
        ans = min(ans, sum);
      }
    }
    cout << ans << "\n";
  }
}
