#include <bits/stdc++.h>
using namespace std;
int64_t const UNDEF = -1;
int64_t const INF = 2 * 1000000 + 5;
int64_t solve(int64_t k, int64_t s) {
  if (k % s == 0) return k / s;
  if (k < s) {
    if (k + 1 == s) return 1;
    return UNDEF;
  }
  int64_t a = s - k % s - 1;
  int64_t b = k / s;
  if (a > b) return UNDEF;
  return k / s + 1;
}
int64_t testSize(int64_t s, vector<int64_t> const &v) {
  int64_t sum = 0;
  for (int64_t i = 0; i < int64_t(v.size()); ++i) {
    int64_t cnt = solve(v[i], s);
    if (cnt == UNDEF) return UNDEF;
    sum += cnt;
  }
  return sum;
}
int64_t selectRes(int64_t res, int64_t newRes) {
  if (newRes == UNDEF) return res;
  return min(res, newRes);
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int64_t t;
  cin >> t;
  vector<int64_t> c;
  vector<int64_t> v;
  c.reserve(2 * 1000000 + 1);
  v.reserve(2 * 1000000 + 1);
  while (t--) {
    c.clear();
    v.clear();
    int64_t n;
    cin >> n;
    c.resize(n);
    for (int64_t i = 0; i < int64_t(n); ++i) {
      cin >> c[i];
    }
    sort(c.begin(), c.end());
    int64_t cnt = 0;
    int64_t p = c[0];
    for (int64_t i = 0; i < int64_t(n); ++i) {
      if (c[i] == p) {
        ++cnt;
      } else {
        v.push_back(cnt);
        cnt = 1;
        p = c[i];
      }
    }
    v.push_back(cnt);
    int64_t vMin = *min_element(v.begin(), v.end());
    int64_t res = INF;
    for (int64_t x = 1; x <= vMin + 1; ++x) {
      res = selectRes(res, testSize(x, v));
    }
    cout << res << "\n";
  }
  return 0;
}
