#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tichnas;
  cin >> tichnas;
  while (tichnas--) {
    long long n, c, m, maxs = 1e9, temp, ans;
    map<long long, long long> type;
    bool possible;
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> c;
      type[c]++;
    }
    for (auto it = type.begin(); it != type.end(); it++)
      maxs = min(maxs, it->second + 1);
    ans = n;
    for (int i = 2; i <= maxs; i++) {
      possible = true;
      m = 0;
      for (auto it = type.begin(); it != type.end() && possible; it++) {
        temp = it->second;
        if (temp % i == 0)
          m += temp / i;
        else if (i - 1 - temp % i <= temp / i)
          m += temp / i + 1;
        else
          possible = false;
      }
      if (possible) ans = m;
    }
    cout << ans << '\n';
  }
  return 0;
}
