#include <bits/stdc++.h>
using namespace std;
int unique_num[2000005], mem = 0;
int counter[2000005];
int amount;
bool good(int par) {
  int total = 0;
  for (int i = 1; i <= mem; i++) {
    int diver = counter[unique_num[i]] / par;
    int remain = counter[unique_num[i]] % par;
    if (remain != 0 && par - 1 - remain > diver) return false;
    total += diver + (remain > 0);
  }
  printf("%d\n", total);
  return true;
}
void solve() {
  for (int i = 1; i <= mem; i++) counter[unique_num[i]] = 0;
  mem = 0;
  scanf("%d", &amount);
  for (int i = 1; i <= amount; i++) {
    int num;
    scanf("%d", &num);
    counter[num]++;
    if (counter[num] == 1) unique_num[++mem] = num;
  }
  int max_counter = 0;
  for (int i = 1; i <= mem; i++)
    max_counter = max(max_counter, counter[unique_num[i]]);
  for (int i = max_counter; i >= 1; i--) {
    int diver = max_counter / i;
    int remain = max_counter % i;
    if (remain != 0 && i - 1 - remain > diver) continue;
    if (good(i)) return;
  }
}
int main() {
  int tester;
  scanf("%d", &tester);
  while (tester--) solve();
}
