#include <bits/stdc++.h>
using namespace std;
const int N = 2e6 + 10;
int L[N], R[N], q[N], f[N], g[N], a[N];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) f[i] = 0, q[i] = 0;
    for (int i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      a[i] = x;
      f[x]++;
    }
    int tot = 0;
    for (int i = 1; i <= n; i++)
      if (f[i]) a[++tot] = f[i], f[i] = 0;
    for (int i = 1; i <= tot; i++) f[a[i]] = 1;
    g[n + 1] = n + 1;
    for (int i = n; i; i--)
      if (f[i])
        g[i] = i;
      else
        g[i] = g[i + 1];
    g[0] = g[1];
    int Ans = 1;
    for (int i = 2; i <= n; i++) {
      int m = n / i;
      for (int j = 0; j <= m; j++) {
        L[j] = i * j;
        R[j] = min(n, i * (j + 1) - 1);
      }
      for (int j = 0; j <= m; j++) {
        q[j] = g[L[j] + 1];
        if (q[j] > R[j]) q[j] = 0;
      }
      int flag = 0;
      for (int j = 0; j <= m; j++) {
        if (!q[j]) continue;
        int x = q[j];
        if (x % i + x / i < i - 1) {
          flag = 1;
          break;
        }
      }
      if (!flag) Ans = max(Ans, i);
    }
    int S = 0;
    for (int i = 1; i <= tot; i++)
      if (a[i] % Ans)
        S += a[i] / Ans + 1;
      else
        S += a[i] / Ans;
    printf("%d\n", S);
  }
}
