#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> cnt(n + 1, 0);
    vector<int> temp;
    for (int i = 0; i < n; ++i) {
      int v;
      cin >> v;
      if (cnt[v] == 0) temp.push_back(v);
      cnt[v]++;
    }
    int cur = 1e9;
    for (int i = 0; i <= n; ++i) {
      if (cnt[i]) cur = min(cur, cnt[i]);
    }
    for (auto& j : temp) j = cnt[j];
    int ans = 1e9;
    for (int i = 2; i <= cur + 1; ++i) {
      int count = 0;
      int f = 0;
      for (auto& j : temp) {
        int k = (i - j % i) % i;
        if (k * i - k > j)
          f = 1;
        else {
          count += k + (j - k * (i - 1)) / i;
        }
      }
      if (f) {
        continue;
      }
      ans = min(ans, count);
    }
    cout << ans << '\n';
  }
  return 0;
}
