#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int m, int ans = 1) {
  for (; b; b >>= 1, a = 1LL * a * a % m)
    if (b & 1) ans = 1LL * ans * a % m;
  return ans;
}
const int N = 2e6 + 10;
int a[N], b[N];
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) b[i] = 0;
    int t;
    for (int i = 1; i <= n; i++) {
      scanf("%d", &t);
      b[t]++;
    }
    int mn = 0x3f3f3f3f, m = 0;
    for (int i = 1; i <= n; i++)
      if (b[i]) mn = min(mn, b[i] + 1), a[++m] = b[i];
    n = m;
    int ans = 0x3f3f3f3f;
    for (int s = 1; s <= mn; s++) {
      int tmp = 0;
      for (int i = 1; i <= n; i++) {
        int m = (a[i] + s - 1) / s;
        if (s * m - a[i] > m) {
          tmp = 0x3f3f3f3f;
          break;
        }
        tmp += m;
      }
      ans = min(ans, tmp);
    }
    printf("%d\n", ans);
  }
  return 0;
}
