#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int arr[n];
    std::vector<pair<long long int, long long int>> v;
    for (int i = 0; i < n; ++i) {
      cin >> arr[i];
    }
    sort(arr, arr + n);
    long long int cnt = 1;
    for (int i = 1; i < n; ++i) {
      if (arr[i] == arr[i - 1])
        cnt++;
      else {
        v.push_back(make_pair(cnt, arr[i - 1]));
        cnt = 1;
      }
    }
    v.push_back(make_pair(cnt, arr[n - 1]));
    sort(v.begin(), v.end());
    long long int ans = 0;
    long long int low = 0;
    long long int high = n - 2;
    while (low <= high) {
      long long int mid = (low + high) / 2;
      long long int a = 1;
      bool flag = true;
      for (int i = v.size() - 1; i >= 0; i--) {
        if (v[i].first <= 1) continue;
        long long int tn = a + (v[i].first - 1) * (mid + 1);
        a++;
        if (tn > n) {
          flag = false;
          break;
        }
      }
      if (flag == true) {
        ans = mid;
        low = mid + 1;
      } else {
        high = mid - 1;
      }
    }
    cout << ans << endl;
  }
}
