#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
using namespace std;
using namespace chrono;
long long int advceil(long long int num, long long int den) {
  return (num % den == 0 ? num / den : num / den + 1);
}
long long int lstbt(long long int val) {
  long long int msk = val & (val - 1);
  return log2(val ^ msk);
}
long long int modexpo(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res % 1000000007 * a % 1000000007) % 1000000007;
    a = (a % 1000000007 * a % 1000000007);
    b /= 2;
  }
  return res;
}
long long int expo(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = (res * a);
    a = (a * a);
    b /= 2;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  return a == 0 ? b : gcd(b % a, a);
}
vector<long long int> CALCfactor(long long int n) {
  vector<long long int> factor(n + 2, 0);
  for (long long int i = 4; i <= n; i += 2) factor[i] = 2;
  for (long long int j = 3; j <= n; j += 2) {
    if (factor[j]) continue;
    for (long long int i = 2 * j; i <= n; i += j) factor[i] = j;
  }
  return factor;
}
vector<long long int> CALCprimeNUM(long long int n) {
  vector<long long int> factor = CALCfactor(n);
  vector<long long int> primeNUM;
  primeNUM.reserve(n + 2);
  for (long long int i = 2; i <= n; i++)
    if (!factor[i]) primeNUM.push_back(i);
  return primeNUM;
}
vector<long long int> CALCprimeFACTOR(long long int n) {
  vector<long long int> factor = CALCfactor(n);
  vector<long long int> ans;
  while (factor[n] != 0) {
    ans.push_back(factor[n]);
    n /= factor[n];
  }
  ans.push_back(n);
  return ans;
}
vector<long long int> unique(vector<long long int> x) {
  sort(x.begin(), x.end());
  set<long long int> s;
  vector<long long int> ans;
  ans.reserve(x.size());
  for (auto elem : x) s.insert(elem);
  for (auto elem : s) ans.push_back(elem);
  return ans;
}
vector<long long int> ZALGO(string s, string pat) {
  long long int lens = pat.length();
  pat += char(36);
  pat += s;
  s = pat;
  vector<long long int> pref(s.length() + 1, 0);
  pref[0] = s.length();
  long long int spt = -1;
  long long int ept = -1;
  long long int processCnt = 0;
  for (long long int i = 1; i < s.length(); i++) {
    bool isdone = false;
    if (i <= ept and i >= spt) {
      if (pref[i - spt] + i <= ept) pref[i] = pref[i - spt], isdone = true;
      processCnt++;
    }
    if (!isdone) {
      long long int ptr = i;
      long long int lo = 0;
      while (s[lo] == s[ptr]) ptr++, lo++, processCnt++;
      if (ept < ptr - 1) {
        spt = i;
        ept = ptr - 1;
      }
      pref[i] = lo;
    }
  }
  vector<long long int> ans;
  ans.reserve(s.length() - lens);
  for (long long int i = lens + 1; i < s.length(); i++) ans.push_back(pref[i]);
  return ans;
}
void spclSort(
    vector<pair<pair<long long int, long long int>, long long int>> &v) {
  long long int n = v.size();
  {
    vector<long long int> cnt(n);
    for (auto elem : v) {
      cnt[elem.first.second]++;
    }
    vector<pair<pair<long long int, long long int>, long long int>> a_new(n);
    vector<long long int> pos(cnt.size());
    pos[0] = 0;
    for (long long int i = 1; i < cnt.size(); i++) {
      pos[i] = cnt[i - 1] + pos[i - 1];
    }
    for (auto elem : v) {
      a_new[pos[elem.first.second]] = elem;
      pos[elem.first.second]++;
    }
    v = a_new;
  }
  {
    vector<long long int> cnt(n, 0);
    for (auto elem : v) {
      cnt[elem.first.first]++;
    }
    vector<pair<pair<long long int, long long int>, long long int>> a_new(n);
    vector<long long int> pos(cnt.size());
    pos[0] = 0;
    for (long long int i = 1; i < cnt.size(); i++) {
      pos[i] = cnt[i - 1] + pos[i - 1];
    }
    for (auto elem : v) {
      a_new[pos[elem.first.first]] = elem;
      pos[elem.first.first]++;
    }
    v = a_new;
  }
}
pair<vector<vector<long long int>>, vector<vector<long long int>>> getOrdering(
    string s) {
  s += char(36);
  vector<vector<long long int>> dp;
  dp.reserve(log2(s.length()) + 3);
  vector<vector<long long int>> dp2;
  dp2.reserve(log2(s.length()) + 3);
  vector<long long int> ordering(s.length()), eqClass(s.length());
  {
    vector<pair<char, long long int>> temp(s.length());
    for (long long int i = 0; i < s.length(); i++) temp[i] = {s[i], i};
    sort(temp.begin(), temp.end());
    for (long long int i = 0; i < temp.size(); i++)
      ordering[temp[i].second] = i;
    eqClass[temp[0].second] = 0;
    for (long long int i = 1; i < temp.size(); i++) {
      if (temp[i].first != temp[i - 1].first)
        eqClass[temp[i].second] = eqClass[temp[i - 1].second] + 1;
      else
        eqClass[temp[i].second] = eqClass[temp[i - 1].second];
    }
    dp.push_back(ordering);
    dp2.push_back(eqClass);
  }
  long long int k = 1;
  while ((1 << (k - 1)) < s.length()) {
    vector<pair<pair<long long int, long long int>, long long int>> arr(
        s.length());
    for (long long int i = 0; i < s.length(); i++) {
      arr[i] = {{eqClass[i], eqClass[(i + (1 << (k - 1))) % s.length()]}, i};
    }
    spclSort(arr);
    for (long long int i = 0; i < s.length(); i++) ordering[arr[i].second] = i;
    eqClass[arr[0].second] = 0;
    for (long long int i = 1; i < s.size(); i++) {
      if (arr[i].first != arr[i - 1].first)
        eqClass[arr[i].second] = eqClass[arr[i - 1].second] + 1;
      else
        eqClass[arr[i].second] = eqClass[arr[i - 1].second];
    }
    dp.push_back(ordering);
    dp2.push_back(eqClass);
    k++;
  }
  return {dp, dp2};
}
vector<long long int> sortOrdering(vector<vector<long long int>> dp) {
  vector<long long int> arr = dp[dp.size() - 1];
  vector<long long int> ans(arr.size());
  long long int cnt = 0;
  for (auto elem : arr) {
    ans[elem] = cnt;
    cnt++;
  }
  return ans;
}
vector<long long int> getLps(string pat) {
  long long int i = 1;
  long long int j = 0;
  vector<long long int> lps(pat.length(), 0);
  lps[0] = 0;
  while (i < pat.length()) {
    if (pat[i] == pat[j])
      lps[i] = j + 1, i++, j++;
    else if (j == 0)
      lps[i] = 0, i++;
    else
      j = lps[j - 1];
  }
  return lps;
}
bool comp(long long int a, long long int b) { return a > b; }
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> arr(n);
  for (long long int i = 0; i < n; i++) cin >> arr[i];
  ;
  long long int lo = 0;
  long long int hi = n - 1;
  long long int ans = -1;
  while (lo <= hi) {
    long long int mid = (lo + hi) / 2;
    bool canweplace = true;
    vector<long long int> freq(n + 1, 0);
    for (long long int i = 0; i < n; i++) freq[arr[i]]++;
    set<pair<long long int, long long int>,
        greater<pair<long long int, long long int>>>
        s;
    for (long long int i = 0; i <= n; i++)
      if (freq[i] > 0) s.insert({freq[i], i});
    vector<long long int> b;
    b.reserve(n + 1);
    b.push_back(-1);
    for (long long int i = 1; i <= n; i++) {
      if (i > mid + 1 and freq[b[i - mid - 1]]) {
        s.insert({freq[b[i - mid - 1]], b[i - mid - 1]});
      }
      if (s.empty()) {
        canweplace = false;
        break;
      }
      pair<long long int, long long int> elem = *(s.begin());
      s.erase(s.begin());
      b.push_back(elem.second);
      freq[elem.second]--;
    }
    if (canweplace) {
    }
    if (canweplace) {
      ans = mid;
      lo = mid + 1;
    } else {
      hi = mid - 1;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  auto start1 = high_resolution_clock::now();
  long long int t;
  cin >> t;
  while (t--) solve();
  auto stop1 = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop1 - start1);
}
