#include <bits/stdc++.h>
using namespace std;
long long arr[2000002];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  for (long long o = 0; o < t; o++) {
    long long n;
    cin >> n;
    for (long long i = 1; i <= n; i++) {
      long long x;
      cin >> x;
      arr[x]++;
    }
    vector<long long> vi;
    for (long long i = 1; i <= n; i++)
      if (arr[i]) vi.push_back(arr[i]);
    sort(vi.begin(), vi.end());
    long long ans = 1e18;
    for (long long s = 1; s <= vi[0] + 1; s++) {
      long long can = 1;
      long long sum = 0;
      for (long long x : vi) {
        if (s == 1)
          sum += x;
        else {
          long long rv = x / (s - 1);
          long long lv = (x + s - 1) / s;
          if (lv > rv)
            can = 0;
          else
            sum += lv;
        }
      }
      if (can) ans = min(ans, sum);
    }
    cout << ans << '\n';
    for (long long i = 1; i <= n; i++) arr[i] = 0;
  }
  return 0;
}
