#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int exgcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1, y = 0;
    return a;
  }
  int d = exgcd(b, a % b, y, x);
  y -= a / b * x;
  return d;
}
bool check(int x) {
  int a, b, d, t;
  for (auto i : mp) {
    int p = i.second;
    d = exgcd(x - 1, x, a, b);
    if (p % d == 0) {
      a *= p / d;
      t = x / d;
      t = abs(t);
      a = (a % t + t) % t;
    }
    b = (p - a * (x - 1)) / x;
    if (p < b * x || p < a * (x - 1)) {
      return false;
    }
  }
  return true;
}
int main() {
  int T, n;
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (~scanf("%d", &T)) {
    while (T--) {
      scanf("%d", &n);
      int temp = 0;
      mp.clear();
      for (int i = 0; i < n; i++) {
        scanf("%d", &temp);
        mp[temp]++;
      }
      int Min = 99999999;
      for (auto i : mp) {
        Min = min(i.second, Min);
      }
      int p = sqrt(Min) + 1;
      int tmp = Min + 1;
      int ans = 0, x;
      if (check(tmp)) {
        ans = tmp;
        goto end;
      }
      for (int i = 1; i <= p; i++) {
        x = Min / i;
        if (x == 2 && !(Min % i)) {
          if (check(3)) {
            ans = 3;
            break;
          }
          ans = 2;
          break;
        }
        if (check(x + 1)) {
          ans = x + 1;
          break;
        }
        if (check(x)) {
          ans = x;
          break;
        }
      }
    end:
      int a, b, d, t, cnt = 0;
      for (auto i : mp) {
        p = i.second;
        if (ans != 2) {
          d = exgcd(ans - 1, ans, a, b);
          if (p % d == 0) {
            a *= p / d;
            t = ans / d;
            t = abs(t);
            a = (a % t + t) % t;
          }
          cnt += a + (p - a * (ans - 1)) / ans;
        } else {
          cnt += (p + 1) / ans;
        }
      }
      cout << cnt << endl;
    }
  }
  return 0;
}
