#include <bits/stdc++.h>
using namespace std;
inline void solve() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < (n); i++) {
      int t;
      cin >> t;
      mp[t]++;
    }
    int mn = 200000000;
    for (pair<int, int> x : mp) mn = min(x.second, mn);
    int otv = n;
    for (int i = 2; i < (mn + 2); i++) {
      bool is = 1;
      int o = 0;
      for (pair<int, int> x : mp) {
        int d = x.second / i;
        int ost = x.second % i;
        if (ost != 0 && (i - ost - 1) > d) {
          is = 0;
          break;
        } else if (ost != 0)
          d++;
        o += d;
      }
      if (is) otv = min(otv, o);
    }
    cout << otv << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
