#include <bits/stdc++.h>
using namespace std;
int a[2000006];
bool cmp(int x, int y) { return x > y; }
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n;
    scanf("%d", &n);
    for (int i = 0; i <= n; i++) a[i] = 0;
    for (int i = 1; i <= n; i++) {
      int x;
      scanf("%d", &x);
      a[x]++;
    }
    sort(a + 1, a + n + 1, cmp);
    int mi = n;
    for (int i = 1; i <= n; i++) {
      if (a[i] == 0) break;
      mi = min(mi, a[i]);
    }
    int ans = n;
    for (int i = 2; i <= mi + 1; i++) {
      int sum = 0, v = 0;
      for (int j = 1; j <= n; j++) {
        if (a[j] == 0) break;
        if (a[j] % i == 0)
          sum = sum + a[j] / i;
        else {
          int x = a[j] % i;
          int y = a[j] / i;
          if (y < i - 1 - x) {
            v = 1;
            break;
          }
          sum = sum + y + 1;
        }
      }
      if (v == 0 && sum > 0) ans = min(ans, sum);
    }
    printf("%d\n", ans);
  }
}
