#include <bits/stdc++.h>
using namespace std;
const int maxn = 2200000;
int n;
int c[maxn];
int x[maxn];
int answer() {
  vector<int> occ;
  for (int i = 0; i < n; i++) {
    if (x[i] > 0) occ.push_back(x[i]);
  }
  int z = *min_element(occ.begin(), occ.end()) + 1;
  for (; z > 1; z--) {
    int ans = 0;
    bool flg = true;
    for (const auto& a : occ) {
      int q = (a + z - 1) / z;
      int r = z * q - a;
      if (q < r) {
        flg = false;
        break;
      } else
        ans += q;
    }
    if (flg) return ans;
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  for (int TN = 0; TN < T; TN++) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> c[i];
      c[i]--;
    }
    for (int i = 0; i < n; i++) x[c[i]]++;
    cout << answer() << '\n';
    for (int i = 0; i < n; i++) x[i] = 0;
  }
  return 0;
}
