#include <bits/stdc++.h>
using namespace std;
int tc, n;
int C[2000005];
vector<int> occ;
int main() {
  scanf("%d", &tc);
  while (tc--) {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
      scanf("%d", &C[i]);
    }
    sort(C, C + n);
    occ.clear();
    int cnt = 1;
    for (int i = 1; i < n; i++) {
      if (C[i] == C[i - 1]) {
        cnt++;
      } else {
        occ.push_back(cnt);
        cnt = 1;
      }
    }
    occ.push_back(cnt);
    sort(occ.begin(), occ.end());
    int opts = n;
    for (int s = 1; s <= occ[0] + 1; s++) {
      int zen = 0;
      for (int i = 0; i < occ.size(); i++) {
        int qi = occ[i] / s;
        if (occ[i] % s > 0) qi++;
        if (occ[i] < qi * (s - 1)) {
          zen = 1e9;
          break;
        }
        zen += qi;
      }
      if (zen < opts) opts = zen;
    }
    printf("%d\n", opts);
  }
  return 0;
}
