Pinkie Pie has bought a bag of patty-cakes with different fillings! But it appeared that not all patty-cakes differ from one another with filling. In other words, the bag contains some patty-cakes with the same filling.

Pinkie Pie eats the patty-cakes one-by-one. She likes having fun so she decided not to simply eat the patty-cakes but to try not to eat the patty-cakes with the same filling way too often. To achieve this she wants the minimum distance between the eaten with the same filling to be the largest possible. Herein Pinkie Pie called the distance between two patty-cakes the number of eaten patty-cakes strictly between them.

Pinkie Pie can eat the patty-cakes in any order. She is impatient about eating all the patty-cakes up so she asks you to help her to count the greatest minimum distance between the eaten patty-cakes with the same filling amongst all possible orders of eating!

Pinkie Pie is going to buy more bags of patty-cakes so she asks you to solve this problem for several bags!


-----Input-----

The first line contains a single integer $T$ ($1 \le T \le 100$): the number of bags for which you need to solve the problem.

The first line of each bag description contains a single integer $n$ ($2 \le n \le 10^5$): the number of patty-cakes in it. The second line of the bag description contains $n$ integers $a_1, a_2, \ldots, a_n$ ($1 \le a_i \le n$): the information of patty-cakes' fillings: same fillings are defined as same integers, different fillings are defined as different integers. It is guaranteed that each bag contains at least two patty-cakes with the same filling. 

It is guaranteed that the sum of $n$ over all bags does not exceed $10^5$.


-----Output-----

For each bag print in separate line one single integer: the largest minimum distance between the eaten patty-cakes with the same filling amongst all possible orders of eating for that bag.


-----Example-----
Input
4
7
1 7 1 6 4 4 6
8
1 1 4 6 4 6 4 7
3
3 3 3
6
2 5 2 3 1 4

Output
3
2
0
4



-----Note-----

For the first bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): $1$, $6$, $4$, $7$, $1$, $6$, $4$ (in this way, the minimum distance is equal to $3$).

For the second bag Pinkie Pie can eat the patty-cakes in the following order (by fillings): $1$, $4$, $6$, $7$, $4$, $1$, $6$, $4$ (in this way, the minimum distance is equal to $2$).

Source: codeforces | Difficulty: MEDIUM_HARD
Tags: Greedy algorithms

Sorting

Mathematics

Constructive algorithms


Solutions:
from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	x = Counter(a)
	m = max(x.values())
	s = list(x.values()).count(m)
	x = n - s * m
	x = x // (m - 1)
	print(x + s - 1)


for _ in range(int(input())):
	n = int(input())
	cnt = [0 for i in range(n + 1)]
	b = list(map(int, input().split()))
	for u in b:
		cnt[u] += 1
	mxfq = max(cnt)
	tot = 0
	for u in cnt:
		tot += min(u, mxfq - 1)
	print((tot - (mxfq - 1)) // (mxfq - 1))


from collections import Counter, defaultdict
from sys import stdin, stdout
input = stdin.readline
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))

def solve():
	n = I()
	l = LI()
	d = Counter(l)
	a = list(d.values())
	m = max(a)
	c = a.count(m)
	ans = n - m - c + 1
	print(ans // (m - 1))
for _ in range(I()):
	solve()


import math
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		dp = [0] * n
		for i in arr:
			dp[i - 1] += 1
		m = max(dp)
		c = dp.count(m)
		print((n - c) // (m - 1) - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	freq = {}
	max_freq = 0
	for i in a:
		freq[i] = (freq.get(i) or 0) + 1
		max_freq = max(max_freq, freq[i])
	count = 0
	max_freq_count = 0
	for i in freq:
		if freq[i] < max_freq:
			count += freq[i]
		else:
			max_freq_count += 1
	if max_freq == 1:
		ans = n
	else:
		ans = count // (max_freq - 1) + max_freq_count - 1
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	ac = dict()
	for i in range(n):
		if a[i] not in ac:
			ac[a[i]] = 1
		else:
			ac[a[i]] += 1
	(u, v) = (0, 0)
	for x in ac:
		if ac[x] > v:
			v = ac[x]
			u = 1
		elif ac[x] == v:
			u += 1
	ans = (n - u * v) // (v - 1)
	ans = ans + u - 1
	print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = Counter(arr)
	l = []
	for i in d:
		l.append(d[i])
	l.sort(reverse=True)
	m = max(l)
	ans = 0
	for i in l[1:]:
		if i == m:
			ans += m - 1
		else:
			ans += i
	print(ans // (m - 1))


from collections import defaultdict
con = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	T = int(input())
	for _ in range(T):
		N = int(input())
		A = getlist()
		D = defaultdict(int)
		for i in A:
			D[i] += 1
		D2 = defaultdict(int)
		for i in D:
			D2[D[i]] += 1
		val = 0
		num = 0
		for i in D2:
			if i > val:
				val = i
				num = D2[i]
		ans = int((N - num) // (val - 1)) - 1
		print(ans)

def __starting_point():
	main()
__starting_point()


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	count = defaultdict(lambda : 0)
	maxlen = 0
	maxc = 0
	for j in range(n):
		count[a[j]] += 1
		if count[a[j]] > maxlen:
			maxlen = count[a[j]]
			maxc = 1
		elif count[a[j]] == maxlen:
			maxc += 1
	g = (n - maxlen - maxc + 1) // (maxlen - 1)
	print(g)


for c in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in range(n):
		if a[i] not in d:
			d[a[i]] = 1
		else:
			d[a[i]] += 1
	d1 = list(d.values())
	m = max(d1)
	count = d1.count(m)
	print((n - count) // (m - 1) - 1)


for _ in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	has = [0] * (n + 1)
	for i in lis:
		has[i] += 1
	has.sort(reverse=True)
	i = 1
	d = 0
	while has[0] == has[i]:
		i += 1
		d += 1
	c = 0
	for j in range(i, n + 1):
		c += has[j]
	d += c // (has[0] - 1)
	print(d)


t = int(input())
for test in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	cnt = [0] * n
	for x in a:
		cnt[x - 1] += 1
	print((n - cnt.count(max(cnt))) // (max(cnt) - 1) - 1)


def solve():
	n = int(input())
	dct = {}
	for i in list(map(int, input().split())):
		dct[i] = dct.get(i, 0) + 1
	maxnum = 0
	maxcl = 0
	for i in dct.values():
		if i == maxnum:
			maxcl += 1
		if i > maxnum:
			maxnum = i
			maxcl = 1
	print((n - maxnum - maxcl + 1) // (maxnum - 1))
for i in range(int(input())):
	solve()


import collections

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		a = collections.Counter(a)
		a = [a[i] for i in a]
		a = sorted(a)[::-1]
		bins = a[0] - 1
		for i in range(1, len(a)):
			if a[i] == a[0]:
				a[i] -= 1
		rem = sum(a[1:])
		print(rem // bins)

def __starting_point():
	main()
__starting_point()


import io, os
from collections import deque
import bisect
RL = lambda : list(map(int, input().split(' ')))
T = int(input())
for _ in range(T):
	n = int(input())
	l = RL()
	dic = [0] * (n + 1)
	for i in range(n):
		dic[l[i]] += 1
	dic.sort(reverse=True)
	st = 0
	for i in range(len(dic)):
		if dic[i] == dic[0]:
			st += 1
		else:
			break
	rem = dic[0] - 1
	cnt = st - 1
	for i in range(st, len(dic)):
		if dic[i] == 0:
			break
		new_rem = max(0, rem - dic[i])
		if new_rem == 0:
			cnt += 1
			rem = dic[0] - 1 - (dic[i] - rem)
		else:
			rem = new_rem
	print(cnt)


T = int(input())
for _ in range(0, T):
	n = int(input())
	s = [int(x) for x in input().split()]
	pos = [0] * (n + 5)
	for i in range(0, len(s)):
		pos[s[i]] += 1
	mx = max(pos)
	c = 0
	for i in range(0, len(pos)):
		if pos[i] == mx:
			c += 1
	rem = n - mx * c
	kk = c - 1
	if mx > 1:
		kk += rem // (mx - 1)
	print(kk)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	f = [0] * n
	for e in a:
		f[e - 1] += 1
	m = max(f)
	c = f.count(m)
	print((n - m * c) // (m - 1) + c - 1)


t = int(input())
for hh in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	d = {}
	for i in li:
		d[i] = d.get(i, 0) + 1
	so_key = sorted(d, key=d.get, reverse=True)
	max_key = so_key[0]
	for i in range(1, len(so_key)):
		if d[so_key[i]] == d[max_key]:
			d[so_key[i]] -= 1
	no_div = d[so_key[0]] - 1
	baaki = 0
	for i in range(1, len(so_key)):
		baaki += d[so_key[i]]
	print(baaki // no_div)


from collections import *
for _ in range(int(input())):
	n = int(input())
	MaxCnt = [0, 0]
	cnt = defaultdict(lambda : 0)
	for i in map(int, input().split()):
		cnt[i] += 1
		if MaxCnt[0] < cnt[i]:
			MaxCnt = [cnt[i], 1]
		elif MaxCnt[0] == cnt[i]:
			MaxCnt[1] += 1
	ans = MaxCnt[1] - 1
	sep = MaxCnt[0] - 1
	curr = 0
	for i in cnt.values():
		curr += i if i != MaxCnt[0] else 0
		if curr >= sep:
			curr -= sep
			ans += 1
	print(ans)


from collections import defaultdict as dd
import math
import sys
input = sys.stdin.readline

def nn():
	return int(input())

def li():
	return list(input())

def mi():
	return list(map(int, input().split()))

def lm():
	return list(map(int, input().split()))

def solve():
	n = nn()
	cakes = lm()
	cake_count = [0] * (n + 10)
	for cake in cakes:
		cake_count[cake] += 1
	most = max(cake_count)
	k = 0
	for num in cake_count:
		if num == most:
			k += 1
	print((n - most * k) // (most - 1) + (k - 1))
q = nn()
for _ in range(q):
	solve()


for t in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	freq = {}
	for num in arr:
		if num in freq:
			freq[num] += 1
		else:
			freq[num] = 1
	l = list(freq.keys())
	l.sort(key=lambda a: -freq[a])
	k = 1
	while k < len(l) and freq[l[k]] == freq[l[0]]:
		k += 1
	val = (n - k) // (freq[l[0]] - 1) - 1
	print(val)


import collections

def cakes(A):
	n = len(A)
	z = collections.Counter(A)
	res = []
	for i in z.keys():
		res.append([z[i], i])
	res.sort(reverse=True)
	chamber = res[0][0] - 1
	vacant = chamber
	count = 0
	for i in range(1, len(res)):
		if res[i][0] >= res[0][0]:
			res[i][0] = res[0][0] - 1
			count += 1
			vacant = chamber
		else:
			freq = res[i][0]
			if freq == chamber:
				count += 1
				vacant = chamber
			else:
				vacant = vacant - freq
				if vacant <= 0:
					count += 1
					vacant = chamber + vacant
	return count
t = int(input())
for i in range(t):
	n = int(input())
	A = [int(i) for i in input().split()][:n]
	print(cakes(A))


import sys
buff_readline = sys.stdin.readline
readline = sys.stdin.readline
INF = 2 ** 60 - 1

def read_int():
	return int(buff_readline())

def read_int_n():
	return list(map(int, buff_readline().split()))

def read_float():
	return float(buff_readline())

def read_float_n():
	return list(map(float, buff_readline().split()))

def read_str():
	return readline().strip()

def read_str_n():
	return readline().strip().split()

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap
from collections import Counter

def slv(N, A):
	aa = []
	for (a, c) in Counter(A).items():
		aa.append([c, a])
	aa.sort()
	m = aa[-1][0]
	bb = [list() for _ in range(m)]
	while aa and aa[-1][0] == m:
		(c, a) = aa.pop()
		for i in range(m):
			bb[i].append(a)
	p = 0
	l = m - 1
	while aa:
		(c, a) = aa.pop()
		for i in range(c):
			bb[(p + i) % l].append(a)
		p += c
		p %= l
	b = []
	for c in bb:
		b.extend(c)
	ans = INF
	p = {}
	for (i, n) in enumerate(b):
		if n in p:
			ans = min(i - p[n], ans)
		p[n] = i
	error_print(b)
	return ans - 1

def ref(N, A):
	from itertools import permutations
	ans = 0
	for a in permutations(A):
		p = {}
		t = INF
		for (i, n) in enumerate(a):
			if n in p:
				t = min(i - p[n], t)
			p[n] = i
		ans = max(t, ans)
	return ans - 1

def main():
	T = read_int()
	for _ in range(T):
		N = read_int()
		A = read_int_n()
		print(slv(N, A))
main()


import sys
input = sys.stdin.readline
from collections import Counter
import math

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input().strip()
	return list(s[:len(s)])

def invr():
	return map(int, input().strip().split())

def from_file(f):
	return f.readline

def solve(A):
	n = len(A)
	counter = Counter(A)
	M = max(counter.values())
	C = sum((1 if v == M else 0 for (k, v) in counter.items()))
	return (n - C * M) // (M - 1) + (C - 1)
t = inp()
for _ in range(t):
	_ = inp()
	A = inlt()
	print(solve(A))


import math
ans_list = []
for i in range(int(input())):
	length = int(input())
	nums = input().split()
	nums = [int(x) for x in nums]
	ctr_list = []
	for j in range(length + 1):
		ctr_list.append(0)
	for j in nums:
		ctr_list[j] += 1
	max_ctr_seen = max(ctr_list)
	multiple_max = 0
	for j in ctr_list:
		if max_ctr_seen == j:
			multiple_max += 1
	min_distance = math.floor((length - multiple_max) / (max_ctr_seen - 1) - 1)
	ans_list.append(min_distance)
for i in ans_list:
	print(i)


import sys
import math
from decimal import *

def I():
	return int(sys.stdin.readline())

def IL():
	return list(map(int, sys.stdin.readline().strip().split()))

def ILS():
	return list(map(str, sys.stdin.readline().strip().split()))

def solve():
	tt = I()
	for ii in range(tt):
		n = I()
		l = IL()
		d = {}
		for ll in l:
			if ll not in d:
				d[ll] = 1
			else:
				d[ll] += 1
		dd = {}
		for x in d:
			p = d[x]
			if p not in dd:
				dd[p] = 1
			else:
				dd[p] += 1
		val = 0
		for p in d:
			val = max(val, d[p])
		rest = len(l) - dd[val] * val
		ans = rest // (val - 1) + dd[val] - 1
		print(ans)
		pass
solve()


for _ in range(int(input())):
	n = int(input())
	lst = [int(x) for x in input().split()]
	r = [0] * (n + 1)
	for elem in lst:
		r[elem] += 1
	r.sort()
	m = r[-1]
	h = r.count(m)
	print((n - h) // (m - 1) - 1)


from collections import Counter

def min_MaxFunc(n, cake_list):
	c_list = Counter(cake_list)
	occurr_arr = []
	for i in c_list:
		occurr_arr.append(c_list[i])
	max_occurr = max(occurr_arr)
	count = 0
	for i in range(len(occurr_arr)):
		if occurr_arr[i] == max_occurr:
			count += 1
	temp = n - count * max_occurr
	final_ans = temp // (max_occurr - 1) + (count - 1)
	return final_ans
t = int(input())
temp_arr = []
for i in range(t):
	n = int(input())
	cake_list = list(map(int, input().split()))
	max_distance = min_MaxFunc(n, cake_list)
	temp_arr.append(max_distance)
for j in temp_arr:
	print(j)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	for i in a:
		d[i] = d.get(i, 0) + 1
	l = list(d.values())
	l.sort(reverse=True)
	x = l[0] - 1
	out = 0
	cnt = 0
	for i in range(1, len(l)):
		if l[i] > x:
			out += 1
		else:
			cnt += l[i]
	out += cnt // x
	print(out)


from collections import Counter

def H1():
	t = int(input())
	ans = []
	for _ in range(t):
		n = int(input())
		cakes = [int(i) for i in input().split()]
		dups = dict(Counter(cakes).most_common())
		maxdup = max(dups.values())
		numMax = len([k for (k, v) in dups.items() if v == maxdup])
		sol = (n - numMax) / (maxdup - 1)
		ans.append(int(sol) - 1)
	for i in ans:
		print(i)
H1()


from collections import defaultdict
t = int(input())
while t:
	t -= 1
	n = int(input())
	lst = list(map(int, input().split()))
	dic = defaultdict(int)
	for i in lst:
		dic[i] += 1
	max_ele = 0
	counter = 0
	for i in dic.values():
		if max_ele < i:
			counter = 1
			max_ele = i
		elif max_ele == i:
			counter += 1
	res = counter - 1
	if n - max_ele * counter != 0:
		res += (n - max_ele * counter) // (max_ele - 1)
	print(res)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = [int(c) for c in input().split()]
	dic = dict(Counter(arr))
	maxx = max(dic.values())
	maxFreq = 0
	for (i, j) in dic.items():
		if j == maxx:
			maxFreq += 1
	ans = n - maxFreq
	ans = ans // (maxx - 1)
	ans -= 1
	print(ans)


import heapq
T = int(input())
for test in range(T):
	n = int(input())
	l = dict()
	for v in map(int, input().split()):
		if v not in l:
			l[v] = 0
		l[v] += 1
	lo = 0
	hi = n
	while hi - lo > 1:
		test = (lo + hi) // 2
		so_far = []
		ll = dict(l)
		q = []
		works = True
		for v in l:
			heapq.heappush(q, -ll[v])
		for i in range(n):
			if i >= test:
				v = so_far[i - test]
				if v:
					heapq.heappush(q, -v)
			if q:
				nex = -heapq.heappop(q)
				so_far.append(nex - 1)
			else:
				works = False
				break
		if works:
			lo = test
		else:
			hi = test
	print(lo - 1)


import os
import sys
from io import BytesIO, IOBase
from collections import Counter

def main():
	for _ in range(int(input())):
		nn = int(input())
		a = list(map(int, input().split(' ')))
		mc = list(map(list, sorted(Counter(a).items(), key=lambda x: x[1], reverse=True)))
		mxn = mc[0][1]
		cnt = 0
		for x in mc:
			if x[1] == mxn:
				cnt += 1
		print(cnt - 1 + (nn - cnt * mxn) // (mxn - 1) if cnt != 1 else (nn - cnt * mxn) // (mxn - 1))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
T = int(input())
for t in range(T):
	n = int(input())
	A = [int(i) for i in input().split()]
	d = defaultdict(int)
	max_occur = 0
	for a in A:
		d[a] += 1
		max_occur = max(max_occur, d[a])
	max_occur_count = 0
	for a in d:
		if d[a] == max_occur:
			max_occur_count += 1
	print((n - max_occur_count * max_occur) // (max_occur - 1) + max_occur_count - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	numcnt = [0] * (n + 1)
	for i in a:
		numcnt[i] += 1
	numcnt.sort(reverse=True)
	k = n - numcnt[0] + 1
	for i in numcnt:
		if i == numcnt[0]:
			k -= 1
		else:
			break
	ans = k // (numcnt[0] - 1)
	print(ans)


def main():
	t = int(input())
	from collections import defaultdict as dd
	for _ in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		d = dd(lambda : 0)
		for i in a:
			d[i] += 1
		m = max(d.values())
		k = 0
		for i in d.values():
			k += 1 if i == m else 0
		ans = (n - k) // (m - 1) - 1
		print(ans)
	return
main()


import os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import Counter
bags = int(input())
for t in range(bags):
	n = int(input())
	a = list(map(int, input().split()))
	a = Counter(a)
	a1 = [(a[i], i) for i in a if a[i] > 1]
	a1 = sorted(a1)[::-1]
	la = len(a1)
	mv = n + 1
	for (val, i) in a1:
		v = (n - 1) // (val - 1) - 1
		mv = min(mv, v)
		n -= 1
	print(mv)


for _ in range(int(input())):
	n = int(input())
	ls = list(map(int, input().split()))
	space = [0] * (n + 1)
	for i in range(n):
		space[ls[i]] += 1
	space.sort()
	cnt = 1
	for i in range(n):
		if space[n] == space[i]:
			cnt += 1
	print((n - cnt - (space[n] - 1)) // (space[n] - 1))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	co = dict(Counter(li))
	c = 0
	for i in co:
		if co[i] > c:
			c = co[i]
			x = 1
		elif co[i] == c:
			x += 1
	print(x - 1 + (n - c * x) // (c - 1))


import sys, math, heapq, collections, itertools, bisect
sys.setrecursionlimit(101000)

def solve(n, a):
	f = {}
	mf = 0
	for x in a:
		f[x] = f.get(x, 0) + 1
		mf = max(mf, f[x])
	cmf = sum((int(v == mf) for v in f.values()))
	n = n - (cmf - 1)
	if mf == 2:
		return n - 2
	return (n - mf) // (mf - 1)
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(solve(n, a))


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = ri()
	for _ in range(tc):
		n = ri()
		a = ria()
		d = Counter(a)
		k = 0
		for i in d:
			k = max(k, d[i])
		maxfreq = 0
		for i in d:
			if d[i] == k:
				maxfreq += 1
		print((n - maxfreq) // (k - 1) - 1)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
for test in range(t):
	n = int(input())
	array = sorted(list(map(int, input().split())))
	occurance = []
	i = 0
	while i < n - 1:
		if array[i + 1] != array[i]:
			occurance.append(1)
			i += 1
		else:
			j = 1
			while i + j < n and array[i + j] == array[i]:
				j += 1
			else:
				occurance.append(j)
				i += j
	else:
		if array[-1] != array[-2]:
			occurance.append(1)
	occurance.sort()
	occurance.reverse()
	maxm = occurance[0]
	s = 0
	for i in range(len(occurance)):
		if occurance[i] == maxm:
			s += 1
		else:
			break
	n -= s - 1
	print(int((n - maxm) / (maxm - 1)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	mx = float('-inf')
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
		mx = max(mx, d[i])
	cnt = 0
	for (key, val) in d.items():
		if val == mx:
			cnt += 1
	print((n - cnt) // (mx - 1) - 1)


t = int(input())
for case in range(t):
	fill_count = [0] * 100002
	_ = input()
	inp = map(int, input().split(' '))
	for i in inp:
		fill_count[i] += 1
	fill_count = sorted(fill_count, reverse=True)
	m = fill_count[0]
	max_count = fill_count.count(m)
	fillers = sum(fill_count[max_count:])
	res = max_count - 1 + int(fillers / (m - 1))
	print(res)


import sys
read = lambda : sys.stdin.readline().strip()
readi = lambda : map(int, read().split())
from collections import Counter
for _ in range(int(read())):
	n = int(read())
	nums = list(readi())
	counter = Counter(nums)
	counts = [i[1] for i in counter.most_common()]
	max_count = counts[0]
	max_elms_count = 0
	total_count = 0
	for i in range(len(counts)):
		total_count += counts[i]
		if counts[i] == max_count:
			max_elms_count += 1
	max_elms_count -= 1
	ans = (n - max_elms_count - max_count) // (max_count - 1)
	p = max_count - 2
	print(ans)


T = int(input())
for case in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	sums = {}
	for cake in a:
		if sums.get(cake):
			sums[cake] += 1
		else:
			sums[cake] = 1
	sums = list(sums.values())
	sums.sort()
	m = sums[-1]
	nummax = 0
	for sum in sums:
		if sum == m:
			nummax += 1
	ans = (n - nummax) // (m - 1) - 1
	print(ans)


import collections
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	v = collections.Counter(a)
	m = 0
	for i in v:
		if m < v[i]:
			m = v[i]
	s = 0
	count = 0
	for i in v:
		if v[i] != m:
			s += v[i]
		else:
			count += 1
	print(s // (m - 1) + count - 1)


t = int(input())
for i in range(t):
	n = int(input())
	line = list(map(int, input().split()))
	fre = {}
	for val in line:
		if val in fre:
			fre[val] += 1
		else:
			fre[val] = 1
	fre = list(fre.values())
	fre.sort(reverse=True)
	max_f = fre[0]
	ans = 0
	summation = 0
	for f in fre[1:]:
		if max_f == f:
			ans += 1
		else:
			summation += f
	ans += int(summation // (max_f - 1))
	print(ans)


for _ in range(int(input())):
	n = int(input())
	m = 0
	mp = dict()
	arr = list(map(int, input().split()))
	for i in range(n):
		mp[arr[i]] = mp.get(arr[i], 0) + 1
		if mp[arr[i]] > m:
			m = mp[arr[i]]
	if n % 2 == 0:
		if m > n // 2:
			print(0)
			continue
	elif m > (n + 1) // 2:
		print(0)
		continue
	count = 0
	for i in mp:
		if mp[i] == m:
			n -= 1
	n -= m - 1
	m -= 1
	print(n // m)


from collections import Counter, deque
import heapq

def check(h, k):
	q = deque()
	while h:
		(c, e) = heapq.heappop(h)
		q.append((c + 1, e))
		if len(q) > k:
			(c, e) = q.popleft()
			if c < 0:
				heapq.heappush(h, (c, e))
	return all((c == 0 for (c, _) in q))
T = int(input())
for _ in range(T):
	n = int(input())
	p = list(map(int, input().split()))
	h = [(-c, e) for (e, c) in Counter(p).items()]
	heapq.heapify(h)
	(l, r) = (0, n)
	while l < r:
		m = (l + r) // 2
		if check(h.copy(), m):
			l = m + 1
		else:
			r = m
	print(l - 1)


import sys
T = int(sys.stdin.readline().strip())
for t in range(T):
	n = int(sys.stdin.readline().strip())
	a = list(map(int, sys.stdin.readline().strip().split()))
	a.sort()
	m = -1
	mc = 0
	c = 1
	for i in range(1, n):
		if a[i] == a[i - 1]:
			c = c + 1
		else:
			if c > m:
				m = c
				mc = 1
			elif c == m:
				mc = mc + 1
			c = 1
	if c > m:
		m = c
		mc = 1
	elif c == m:
		mc = mc + 1
	print((n - m * mc) // (m - 1) + mc - 1)


from collections import Counter
import math
for x in range(int(input())):
	n = int(input())
	m = list(map(int, input().split()))
	d = Counter(m)
	s = 2
	for i in d:
		if d[i] > s:
			s = d[i]
	l = 0
	for i in d:
		if d[i] == s:
			l += 1
	print((n - l) // (s - 1) - 1)


t = int(input())
for _ in range(t):
	N = int(input())
	A = list(map(int, input().rstrip().split(' ')))
	d = {}
	for i in range(N):
		x = d.get(A[i], -1)
		if x == -1:
			d[A[i]] = 1
		else:
			d[A[i]] = x + 1
	Count = 0
	B = list(d.values())
	y = max(B)
	for x in d:
		if d[x] == y:
			Count += 1
	c = (N - Count * y) // (y - 1)
	print(c + (Count - 1))


for _ in range(int(input())):
	input()
	raw_cakes = [int(i) for i in input().split()]
	cakes = dict()
	for cake in raw_cakes:
		if cake in cakes:
			cakes[cake] += 1
		else:
			cakes[cake] = 1
	amounts = list(sorted(cakes.values()))
	max_ = amounts[-1]
	unused = [0]
	for i in amounts[:-1]:
		unused.append(unused[-1] + i)
	unused.reverse()
	deficit = [0]
	for i in reversed(amounts[:-1]):
		deficit.append(deficit[-1] + max(max_ - 1 - i, 0))
	for i in reversed(range(len(cakes))):
		if deficit[i] <= unused[i]:
			print(i)
			break


import sys, os
from collections import Counter
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
input = lambda : sys.stdin.readline().strip()
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
for _ in range(I()):
	n = I()
	l = li()
	d = dict(Counter(l))
	m = max(d.values())
	cn = n
	c = 0
	for i in d:
		if d[i] == m:
			cn -= m
			c += 1
	print(c - 1 + cn // (m - 1))


cases = int(input())
for i in range(cases):
	n = int(input())
	l2 = input().split(' ')
	arr = []
	for a in l2:
		arr.append(int(a))
	counter = {}
	for ele in arr:
		if ele in counter:
			counter[ele] += 1
		else:
			counter[ele] = 1
	if len(counter) == 1:
		print(0)
		continue
	ma = max(counter.values())
	count = list(counter.values()).count(ma)
	ans = int((n - count) / (ma - 1)) - 1
	print(ans)


from collections import Counter
for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	co = Counter(a)
	hco = co.most_common(1)[0][1]
	l = list(dict(co).values()).count(hco)
	print((n - l) // (hco - 1) - 1)


tests = int(input())
for t in range(tests):
	n = int(input())
	ls = list(map(int, input().split()))
	item_dict = {}
	maxi = 0
	count_maxi = 0
	for item in ls:
		if item in item_dict:
			item_dict[item] += 1
		else:
			item_dict[item] = 1
		if item_dict[item] > maxi:
			maxi = item_dict[item]
			count_maxi = 0
		if item_dict[item] == maxi:
			count_maxi += 1
	others = n - maxi - (count_maxi - 1)
	print(others // (maxi - 1))


import sys
input = sys.stdin.buffer.readline
from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	ct = Counter(arr)
	ans = max(ct.values())
	h = list(ct.values()).count(ans)
	n = n - ans
	n = n - h
	n += 1
	ans -= 1
	print(n // ans)


import sys
import math
import heapq
import collections
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def printspace(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer(' ')

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	mp = [0] * 100001
	mx = 0
	count = 0
	for i in range(n):
		mp[a[i]] += 1
		if mp[a[i]] > mx:
			mx = mp[a[i]]
			count = 1
		elif mp[a[i]] == mx:
			count += 1
	print((n - mx * count) // (mx - 1) + count - 1)


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	v = [0] * (n + 1)
	m = 0
	for i in R():
		v[i] += 1
		m = max(m, v[i])
	mx = v.count(m) - 1
	df = (n - m) // (m - 1)
	k = (n - m) % (m - 1)
	print(df - (max(0, mx - k) + m - 2) // (m - 1))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	n = int(inp())
	a = lis()
	cnt = [0] * (10 ** 5 + 1)
	for i in range(n):
		cnt[a[i]] += 1
	mx = max(cnt)
	help = cnt.count(mx)
	print(floor((n - help - mx + 1) / (mx - 1)))
testcase(int(inp()))


import math
T = int(input())
for i in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	d = False
	A = [0] * n
	for i in range(n):
		A[a[i] - 1] += 1
	ma = max(A)
	man = A.count(ma)
	print((n - man) // (ma - 1) - 1)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	d = {}
	for i in arr:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	freq = []
	for i in d:
		freq.append([d[i], i])
	freq.sort(reverse=True)

	def func(mid):
		ans = [-1 for i in range(n)]
		ind = 0
		for i in freq:
			(f, num) = i
			g = ind
			while f > 0:
				if g >= n:
					return False
				ans[g] = 1
				g += mid + 1
				f -= 1
			ind += 1
		return True
	lo = 0
	hi = 1000000
	while lo < hi:
		mid = (lo + hi) // 2
		x = func(mid)
		if x == True:
			lo = mid
		else:
			hi = mid
		if hi - lo == 1:
			break
	if func(hi) == True:
		print(hi)
	else:
		print(lo)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	d = Counter(a)
	s = list(d.values())
	m = max(s)
	cnt = s.count(m)
	rest = n - m - cnt + 1
	print(rest // (m - 1))


from math import *
from collections import *
from random import *
from decimal import Decimal
from heapq import *
from bisect import *
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 5)

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def inp():
	return int(input())

def st1():
	return input().rstrip('\n')
t = inp()
while t:
	t -= 1
	n = inp()
	a = lis()
	f = Counter(a)
	z = max(f.values())
	co1 = 0
	for i in f.keys():
		if f[i] == z:
			co1 += 1
	print((n - co1) // (z - 1) - 1)


from collections import defaultdict
t = int(input())
for case in range(0, t):
	n = int(input())
	A = input().split()
	A = [int(x) for x in A]
	counts = defaultdict(int)
	max_count = 0
	for x in A:
		counts[x] += 1
		max_count = max(max_count, counts[x])
	k = 0
	for x in counts:
		if counts[x] == max_count:
			k += 1
	print((n - k) // (max_count - 1) - 1)


from collections import defaultdict

def main():
	for case in range(int(input())):
		d = defaultdict(lambda : 0)
		n = int(input())
		arr = [int(x) for x in input().split()]
		for x in arr:
			d[x] += 1
		d = dict(d)
		mx = max(d.values())
		mc = []
		for k in d.keys():
			if d[k] == mx:
				mc.append(k)
		r = d[mc[0]]
		empty = len(arr) - r * len(mc)
		ans = empty // (r - 1)
		print(ans + len(mc) - 1)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	freq = [0] * n
	for e in arr:
		freq[e - 1] += 1
	m = max(freq)
	c = freq.count(m)
	print((n - m * c) // (m - 1) + c - 1)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	number = [0] * n
	for num in arr:
		number[num - 1] += 1
	mx = 0
	for num in number:
		mx = max(num, mx)
	val = 0
	for num in number:
		if num == mx:
			val += 1
	n -= val * mx
	val -= 1
	mx -= 1
	val += n // mx
	print(val)


from collections import *
C = Counter
for s in [*open(0)][2::2]:
	x = s.split()
	c = C(C(x).values())
	v = max(c)
	print((len(x) - c[v]) // (v - 1) - 1)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = Counter(a)
	b = m[a[0]]
	for i in m:
		b = max(b, m[i])
	c = 0
	for i in m:
		if m[i] == b:
			c += 1
	ans = (n - c * b) // (b - 1) + c - 1
	print(int(ans))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	num = [0] * (10 ** 5 + 1)
	for i in range(n):
		num[a[i]] += 1
	MAX = max(num)
	maxnum = num.count(MAX)
	print((n - maxnum) // (MAX - 1) - 1)


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	vals = list(map(int, input().split(' ')))
	c = Counter(vals)
	(_, num) = c.most_common()[0]
	if num == n:
		print(0)
		continue
	for i in c:
		if c[i] == num:
			n -= 1
	print(n // (num - 1) - 1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split(' ')]
	freq = {}
	for aa in a:
		if aa not in freq:
			freq[aa] = 0
		freq[aa] += 1
	max_freq = 0
	max_freq_count = 0
	for f in freq.values():
		if f > max_freq:
			max_freq = f
			max_freq_count = 1
		elif f == max_freq:
			max_freq_count += 1
	if max_freq == 1:
		print(len(a) - 1)
		continue
	repeating_count = max_freq_count * max_freq
	rem = int((len(a) - repeating_count) / (max_freq - 1))
	print(rem + (max_freq_count - 1))


import sys
from collections import defaultdict
from functools import lru_cache
from collections import Counter

def mi(s):
	return map(int, s.strip().split())

def lmi(s):
	return list(mi(s))

def mf(f, s):
	return map(f, s)

def lmf(f, s):
	return list(mf(f, s))

def solve(arr):
	counts = Counter(arr)
	vals = counts.values()
	max_count = max(vals)
	num_max = len([v for v in vals if v == max_count])
	total = num_max * max_count
	rest = len(arr) - total
	spaces = max_count - 1
	dist = rest // spaces + num_max - 1
	return dist

def main(arr):
	for case in arr:
		print(solve(case))
cases = []
for (e, line) in enumerate(sys.stdin.readlines()):
	if e == 0:
		continue
	elif e % 2 == 0:
		cases.append(lmi(line))
main(cases)


from sys import stdin, gettrace
from collections import Counter
if gettrace():
	inputi = input
else:

	def input():
		return next(stdin)[:-1]

	def inputi():
		return stdin.buffer.readline()

def solve():
	n = int(inputi())
	aa = [int(a) for a in inputi().split()]
	aac = Counter(aa)
	mc = aac.most_common()
	mcc = 0
	while mcc < len(mc) and mc[mcc][1] == mc[0][1]:
		mcc += 1
	print((n - mcc) // (mc[0][1] - 1) - 1)

def main():
	t = int(inputi())
	for _ in range(t):
		solve()
main()


import math

def tc():
	n = int(input())
	a = list(map(int, input().split()))
	cnts = [0] * (n + 1)
	for x in a:
		cnts[x] += 1
	max_cnt = max(cnts)
	nmax = 0
	others = 0
	for cnt in cnts:
		if cnt == max_cnt:
			nmax += 1
		else:
			others += cnt
	nothers = n - nmax * max_cnt
	ans = nothers // (max_cnt - 1) + nmax - 1
	print(ans)
T = int(input())
for _ in range(T):
	tc()


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	dick = {}
	for i in a:
		dick[i] = dick.get(i, 0) + 1
	freq = list(sorted(dick.values(), reverse=1))
	singles = 0
	while freq:
		if freq[-1] == 1:
			singles += 1
			freq.pop()
		else:
			break
	vals = []
	while freq:
		cnts = 0
		while freq and freq[-1] == 0:
			freq.pop()
		for i in range(len(freq) - 1, -1, -1):
			freq[i] -= 1
			cnts += 1
		if cnts:
			vals.append(cnts - 1)
	vals.sort()
	vals.pop(0)
	k = max(vals)
	for i in range(len(vals)):
		x = k - vals[i]
		if x <= singles:
			vals[i] = k
			singles -= x
		else:
			vals[i] += x
			singles -= x
	for i in range(len(vals)):
		vals[i] += singles // len(vals)
	print(min(vals))


import math
for _ in range(int(input())):
	am = int(input())
	arr = list(map(int, input().split()))
	have = [0] * (am + 5)
	ourSet = []
	for i in range(am):
		have[arr[i]] += 1
		if have[arr[i]] == 1:
			ourSet.append(arr[i])
	l = len(ourSet)

	def f(el):
		return have[el]
	ourSet.sort(key=f, reverse=True)
	biggestAm = have[ourSet[0]]
	deb = []
	needAm = am
	i = 0
	lInd = 0
	s = 0
	added = 0
	while i < needAm + added:
		if have[ourSet[i % l]]:
			deb.append(ourSet[i % l])
			have[ourSet[i % l]] -= 1
			if i % l == 0 and i != 0:
				s += i - added - lInd - 1
				lInd = i - added
		else:
			added += 1
		i += 1
	print(math.floor(s / (biggestAm - 1)))


from collections import Counter
for _ in range(int(input())):
	(n, a) = (int(input()), Counter(map(int, input().split())).most_common())
	e = sum((1 if b[1] == a[0][1] else 0 for b in a))
	print((n - e * a[0][1]) // (a[0][1] - 1) + e - 1)


import sys
input = sys.stdin.readline

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
t = int(input())
for hh in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	d = {}
	for i in li:
		d[i] = d.get(i, 0) + 1
	so_key = sorted(d, key=d.get, reverse=True)
	maxx = so_key[0]
	for i in range(1, len(so_key)):
		if d[so_key[i]] == d[maxx]:
			d[so_key[i]] -= 1
	summ = 0
	for i in range(1, len(so_key)):
		summ += d[so_key[i]]
	print(summ // (d[maxx] - 1))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	mc = [x[1] for x in Counter(map(int, input().split())).most_common()]
	e = mc[0]
	q = 0
	for c in mc:
		if c != e:
			break
		q += 1
	print((n - q) // (e - 1) - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = {i: 0 for i in range(1, n + 1)}
	mx = 0
	for i in a:
		cnt[i] += 1
		mx = max(mx, cnt[i])
	res = 0
	for i in cnt.keys():
		if cnt[i] == mx:
			res += 1
			n -= mx
	res += int(n / (mx - 1))
	print(res - 1)


t = int(input())
for you in range(t):
	n = int(input())
	l = input().split()
	li = [int(i) for i in l]
	hashi = dict()
	for i in li:
		if i in hashi:
			hashi[i] += 1
		else:
			hashi[i] = 1
	maxa = 0
	ans = 0
	for i in hashi:
		maxa = max(maxa, hashi[i])
	for i in hashi:
		if hashi[i] == maxa:
			ans += 1
	z = n - ans - maxa + 1
	print(z // (maxa - 1))


from sys import stdin
from collections import Counter
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = Counter(map(int, input().split()))
	b = a.most_common()
	k = b[0][1]
	e = sum([1 if d == k else 0 for (c, d) in b])
	print((n - e * k) // (k - 1) + e - 1)


import sys
input = sys.stdin.readline

def name(arr):
	s = [arr[0] for i in range(len(arr))]
	if arr == s[:]:
		return 0
	gap = len(arr)
	h = {}
	f = {}
	for ele in arr:
		if ele not in h:
			h[ele] = 1
		else:
			h[ele] += 1
	m = 0
	x = 0
	for ele in h.values():
		if ele not in f:
			f[ele] = 1
		else:
			f[ele] += 1
		if ele >= x:
			m = f[ele]
			x = ele
	return int((len(arr) - m * x) // (x - 1)) + m - 1

def solution():
	n = int(input())
	arr = list(map(lambda x: int(x), input().split()))
	print(name(arr))
t = int(input())
for i in range(0, t):
	solution()


t = int(input())
for i in range(t):
	n = int(input())
	f = input().split()
	a = dict.fromkeys(f, 0)
	for i in range(n):
		a[f[i]] += 1
	ar = sorted(a.values(), reverse=True)
	m = ar[0]
	k = ar.count(m)
	print((n - k) // (m - 1) - 1)


from collections import deque
from collections import OrderedDict
import math
import sys
import os
import threading
import bisect
import operator
import heapq
from atexit import register
from io import BytesIO
import io
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	dp = [0] * 100005
	for i in range(n):
		dp[ar[i]] += 1
	ar.clear()
	for i in range(len(dp)):
		if dp[i] != 0:
			ar.append(dp[i])
	ar.sort()
	maxC = ar[len(ar) - 1]
	sumA = sum(ar)
	answer = 0
	for i in range(len(ar)):
		if ar[i] == maxC:
			answer += 1
			sumA -= maxC
	answer -= 1
	answer += min(sumA // (maxC - 1), len(ar) - 1)
	print(answer)


import sys
input = sys.stdin.readline
from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(item) for item in input().split()]
	cnt = Counter(a)
	max_c = 0
	max_num = 0
	for (key, val) in cnt.items():
		if val > max_c:
			max_num = 1
			max_c = val
		elif val == max_c:
			max_num += 1
	print((n - max_c - max_num + 1) // (max_c - 1))


from collections import Counter
mod = 10 ** 9 + 7
inf = 1 << 60

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	d = dict(Counter(a))
	data = [(value, key) for (key, value) in d.items()]
	data.sort(reverse=True)
	if len(data) == 1:
		print(0)
	else:
		(max_value, maxkey) = data[0]
		(sec_value, seckey) = data[1]
		if max_value > sec_value:
			s = sum((data[i][0] for i in range(1, len(data))))
			ans = s // (max_value - 1)
			print(ans)
			return
		else:
			s = 0
			ans = 0
			for i in range(1, len(data)):
				if data[i][0] == max_value:
					ans += 1
				else:
					s += data[i][0]
			ans += s // (max_value - 1)
			print(ans)
			return

def main():
	t = int(input())
	for i in range(t):
		solve()
	return
main()


t = int(input())
for p in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	count_arr = [0 for i in range(n + 1)]
	for i in arr:
		count_arr[i] += 1
	Max = max(count_arr)
	MaxFreq = count_arr.count(Max)
	print((n - MaxFreq) // (Max - 1) - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	li = list(map(int, input().split()))
	dic = {}
	for i in range(n):
		val = dic.get(li[i], -1)
		if val == -1:
			dic[li[i]] = 1
		else:
			dic[li[i]] = val + 1
	a = list(dic.values())
	temp = max(a)
	count = 0
	for x in dic:
		if dic[x] == temp:
			count += 1
	n_ele = n - count * temp
	n_g = temp - 1
	print(n_ele // n_g + (count - 1))


def sol(lis):
	hash = {}
	m = 0
	for i in lis:
		if i not in hash:
			hash[i] = 1
		else:
			hash[i] += 1
		m = max(hash[i], m)
	c = 0
	for i in hash:
		if hash[i] == m:
			c += 1
	c -= 1
	print((len(lis) - m - c) // (m - 1))
k = int(input())
for i in range(k):
	input()
	lis = list(map(int, input().split(' ')))
	sol(lis)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	freq = {}
	for i in a:
		if i in freq:
			freq[i] += 1
		else:
			freq[i] = 1
	t = max(freq.values())
	ans = 0
	p = 0
	for i in freq.values():
		if i >= t - 1:
			ans += 1
		else:
			p += i
	print(ans - 1 + p // (t - 1))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	dic = {}
	for i in arr:
		if dic.get(i, -1) == -1:
			dic[i] = 1
		else:
			dic[i] += 1
	x = max(dic.values())
	count = 0
	sum1 = 0
	for i in dic:
		if dic[i] == x:
			count += 1
		else:
			sum1 += dic[i]
	sum1 += (x - 1) * (count - 1)
	gaps = x - 1
	out = sum1 // gaps
	print(out)


import collections
for t in range(int(input())):
	n = int(input())
	num = map(int, input().split())
	k = collections.defaultdict(int)
	key = -1
	count = 0
	for i in num:
		k[i] += 1
		if count < k[i]:
			key = i
			count = k[i]
	left = n
	for i in k:
		if k[i] == count:
			left -= 1
	out = left // (count - 1) - 1
	print(out)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	ps = [int(i) for i in sys.stdin.readline().split()]
	pcount = {}
	maxcount = 0
	for p in ps:
		if p not in pcount:
			pcount[p] = 0
		pcount[p] += 1
		maxcount = max(maxcount, pcount[p])
	countmax = 0
	for p in pcount.keys():
		if pcount[p] == maxcount:
			countmax += 1
	gapsize = (n - maxcount * countmax) // (maxcount - 1)
	print(countmax + gapsize - 1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	n = int(ri())
	a = Ri()
	dic = {}
	maxx = -1
	maxxcnt = 0
	for i in a:
		dic[i] = dic.get(i, 0) + 1
		maxx = max(maxx, dic[i])
	for i in dic:
		if dic[i] == maxx:
			maxxcnt += 1
	rem = n - maxx * maxxcnt
	curans = maxxcnt - 1
	holes = maxx - 1
	ans = curans + rem // holes
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	list_ = [0] * n
	for j in a:
		list_[j - 1] += 1
	count = max(list_)
	print((n - list_.count(count)) // (count - 1) - 1)


import os
import heapq
import sys
import math
import operator
from collections import defaultdict
from io import BytesIO, IOBase

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		ar = inpt()
		d = defaultdict(int)
		mx = 0
		for i in ar:
			d[i] += 1
			mx = max(mx, d[i])
		ct = 0
		for i in d.values():
			if i == mx:
				ct += 1
		tp = ct * mx
		n -= tp
		ds = 0
		if mx - 1:
			ds = n // (mx - 1)
		ans = ds + (ct - 1)
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict as dc
ln = 10 ** 5 + 3

def bns(x, mid, vis):
	ct = 1
	for n in range(x):
		if vis[n] > 1:
			v = ct + (vis[n] - 1) * (mid + 1)
			if v > x:
				return 0
			ct += 1
	return 1

def solv():
	x = int(input())
	vis = [0] * ln
	s = list(map(int, input().split()))
	for n in s:
		vis[n] += 1
	vis.sort(reverse=True)
	hi = ln
	lo = 0
	while hi >= lo:
		mid = (hi + lo) // 2
		if bns(x, mid, vis):
			lo = mid + 1
		else:
			hi = mid - 1
	print(lo - 1)
for n in range(int(input())):
	solv()


for i in ' ' * int(input()):
	n = int(input())
	L = list(map(int, input().split()))
	L.sort()
	pt = 0
	M = []
	ct = 0
	while pt < n - 1:
		pt += 1
		ct += 1
		if L[pt] != L[pt - 1]:
			M.append(ct)
			ct = 0
	ct += 1
	M.append(ct)
	M.sort()
	mx = max(M)
	count = 0
	mxcount = 0
	for i in M:
		if i == mx:
			mxcount += 1
		else:
			count += i
	ans = mxcount + count // (mx - 1) - 1
	print(ans)


t = int(input())
ans = []
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	dct = {}
	for x in a:
		val = dct.get(x, 0)
		val += 1
		dct[x] = val
	candies = []
	for no in dct.values():
		candies.append(no)
	candies.sort()
	l = len(candies)
	idx = l - 2
	while idx >= 0 and candies[idx] == candies[l - 1]:
		idx -= 1
	total_mx = l - idx - 1
	gap = (n - candies[l - 1] * total_mx) // (candies[l - 1] - 1) + total_mx - 1
	ans.append(gap)
for x in ans:
	print(x)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	qu = list((0 for i in range(n)))
	for i in arr:
		qu[i - 1] += 1
	qu.sort(reverse=True)
	a = qu[0]
	ans = 0
	for i in qu:
		if a == i:
			ans += 1
	k = n - (ans - 1) * a
	print((k - 1) // (a - 1) - 1 + ans - 1)


for test_i in range(int(input())):
	n = int(input())
	pies = {}
	for pie in list(map(int, input().split())):
		if pie in pies:
			pies[pie] += 1
		else:
			pies[pie] = 1
	(max_pies, max_pie_num) = (0, 0)
	for pie in pies:
		if pies[pie] > max_pie_num:
			max_pie_num = pies[pie]
			max_pies = 1
		elif pies[pie] == max_pie_num:
			max_pies += 1
	print((n - max_pie_num - max_pies + 1) // (max_pie_num - 1))


import collections
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = collections.Counter(a)
	m = -1
	q = 0
	for c in d.keys():
		if d[c] > m:
			m = d[c]
			q = 1
		elif d[c] == m:
			q += 1
	print((n - q * m) // (m - 1) + q - 1)


import sys
input = sys.stdin.readline
LI = lambda : list(map(int, input().strip('\n').split()))
MI = lambda : map(int, input().strip('\n').split())
SI = lambda : input().strip('\n')
II = lambda : int(input().strip('\n'))
for _ in range(II()):
	n = II()
	a = LI()
	cnt = {}
	for v in a:
		cnt[v] = cnt.get(v, 0) + 1
	m = max(cnt.values())
	num = 0
	for v in cnt:
		if cnt[v] == m:
			num += 1
	print((n - num + 1 - m) // (m - 1))


for t in range(int(input())):
	n = int(input())
	v = list(map(int, input().split()))
	fv = [0] * (n + 1)
	for x in v:
		fv[x] += 1
	fv = list(sorted(fv[1:]))
	fv.reverse()
	(same, x) = ([], 0)
	while x < n and fv[x] == fv[0]:
		same.append(x + 1)
		x += 1
	(buck, i) = ([same[:] for i in range(fv[0])], 0)
	for j in range(x, n):
		for z in range(fv[j]):
			buck[i].append(j + 1)
			i = (i + 1) % (fv[0] - 1)
	sol = []
	for i in range(fv[0]):
		for x in buck[i]:
			sol.append(x)
	(lapr, ans) = ([-1] * (n + 1), 1 << 30)
	for i in range(n):
		if lapr[sol[i]] != -1:
			ans = min(ans, i - lapr[sol[i]] - 1)
		lapr[sol[i]] = i
	print(ans)


from collections import Counter

def cake(arr):
	x = Counter(arr)
	mx = max(x.items(), key=lambda s: s[1])[1]
	maxFreq = list(x.values()).count(mx)
	return (len(arr) - maxFreq) // (mx - 1) - 1
for i in range(int(input())):
	a = input()
	lst = list(map(int, input().strip().split()))
	print(cake(lst))


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	cc = Counter(l)
	m = max(cc.values())
	c = list(cc.values()).count(m)
	r = (n - (c - 1) - m) // (m - 1)
	print(r)


import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
from collections import deque as que, defaultdict as vector, Counter
from bisect import bisect as bsearch
from heapq import *
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
inst = lambda : input().decode().rstrip('\n\r')
INF = float('inf')
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	if len(set(a)) == 1:
		print(0)
	else:
		c = Counter(a)
		k = max(c.values())
		eq = 0
		sm = 0
		for i in c:
			if c[i] != k:
				sm += c[i]
			else:
				eq += 1
		k -= 1
		print(eq - 1 + sm // k)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	frequency = [0 for x in range(n + 1)]
	for i in range(n):
		frequency[l[i]] += 1
	max_frequency = max(frequency)
	count = 0
	for i in range(1, n + 1):
		if frequency[i] == max_frequency:
			count += 1
	s = (n - count * max_frequency) // (max_frequency - 1)
	print(s + count - 1)


n = int(input())
for i in range(n):
	m = int(input())
	lst = list(map(int, input().split()))
	dictionary = dict()
	for i in lst:
		if i in dictionary:
			dictionary[i] += 1
		else:
			dictionary[i] = 1
	maxvalue = 0
	for (key, value) in dictionary.items():
		maxvalue = max(maxvalue, value)
	keylst = []
	for (key, value) in dictionary.items():
		if value == maxvalue:
			keylst.append(key)
	keyvalue = len(keylst)
	print(abs((m - keyvalue) // (maxvalue - 1) - 1))


def solve(n, a):
	d = {}
	putted = [-1] * n
	for i in a:
		if d.get(i, -1) == -1:
			d[i] = 1
		else:
			d[i] += 1
	m = 0
	mq = 1
	for (key, value) in sorted(d.items(), reverse=True, key=lambda x: x[1]):
		if m == 0:
			m = value
		elif value == m:
			mq += 1
	print((n - mq) // (m - 1) - 1)
t = int(input())
while t:
	n = int(input())
	a = [int(i) for i in input().split()]
	solve(n, a)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	x = [0] * n
	l = list(map(int, input().split()))
	for i in l:
		x[i - 1] += 1
	x.sort()
	x.reverse()
	m = x[0]
	ap = 0
	for i in x:
		if i == m:
			ap += 1
		else:
			break
	print((n - ap) // (m - 1) - 1)


import heapq
import collections

def solve(arr):
	counter = collections.Counter(arr)
	mx = max(counter.values())
	cnt = list(counter.values()).count(mx)
	n = len(arr)
	if mx == 2:
		return n - cnt - 1
	else:
		return (n - cnt) // (mx - 1) - 1
for _ in range(int(input())):
	n = int(input())
	(*arr,) = map(int, input().split())
	print(solve(arr))


import os
import sys
from io import BytesIO, IOBase
from collections import Counter
from collections import deque
import math

def sin():
	return input()

def ain():
	return list(map(int, sin().split()))

def sain():
	return input().split()

def iin():
	return int(sin())
MAX = float('inf')
MIN = float('-inf')
MOD = 1000000007

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	s = set()
	for p in range(2, n + 1):
		if prime[p]:
			s.add(p)
	return s

def readTree(n, m):
	adj = [deque([]) for _ in range(n + 1)]
	for _ in range(m):
		(u, v) = ain()
		adj[u].append(v)
		adj[v].append(u)
	return adj

def main():
	for _ in range(iin()):
		n = iin()
		l = ain()
		d = {}
		for i in l:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		maxi = max(d.values())
		cc = list(d.values()).count(maxi)
		ans = (n - cc * maxi) // (maxi - 1)
		ans += cc - 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
if os.getcwd() == 'D:\\code':
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


mod = 10 ** 9 + 7

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	val = -1
	sz = 0
	cnt = [0 for i in range(n + 1)]
	for i in range(n):
		cnt[a[i]] += 1
		if val == -1 or cnt[a[i]] > cnt[val]:
			val = a[i]
	for i in range(n + 1):
		if cnt[i] == cnt[val]:
			sz += 1
	cc = cnt[val]
	print(sz - 1 + (n - sz * cc) // (cc - 1))
t = 1
t = int(input())
for _ in range(t):
	solve()


from collections import Counter

def getMinDist(fills, n):
	fills_set = Counter(fills).keys()
	fills_times = list(Counter(fills).values())
	max_occ = max(fills_times)
	fills_times.remove(max_occ)
	all_max = 1
	while fills_times and max_occ == max(fills_times):
		fills_times.remove(max_occ)
		all_max += 1
	remains = sum(fills_times) if fills_times else 0
	dis = all_max - 1 + remains // (max_occ - 1)
	print(dis)
t = int(input())
for _ in range(t):
	n = int(input())
	fills = list(map(int, input().rstrip().split()))
	getMinDist(fills, n)


T = int(input())
for _ in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	c = dict()
	k = 0
	for v in a:
		if v not in c:
			c[v] = 0
		c[v] += 1
	k = max(c.values())
	z = sum((k == z for z in c.values()))
	print((n + 1 - z - k) // (k - 1))


for _ in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	r = [0 for i in range(n + 1)]
	for i in l:
		r[i] += 1
	r.sort()
	m = r[-1]
	h = r.count(m)
	print((n - h) // (m - 1) - 1)


import sys
input = sys.stdin.readline
for f in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	patties = [0] * n
	mx = 0
	for p in a:
		patties[p - 1] += 1
		mx = max(patties[p - 1], mx)
	mxs = 0
	for p in patties:
		if p == mx:
			mxs += 1
	rest = n - mx
	rest -= mxs
	rest += 1
	spots = mx - 1
	print(rest // spots)


t = int(input())
from collections import Counter
for _ in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	C = Counter(A)
	D = list(C.items())
	D.sort(key=lambda x: -x[1])
	if len(D) == 1:
		print(0)
		continue
	(k0, v0) = D[0]
	ans = 0
	cnt = 0
	for i in range(1, len(D)):
		(k, v) = D[i]
		if v >= v0 - 1:
			ans += 1
		else:
			cnt += v
		if cnt >= v0 - 1:
			ans += 1
			cnt = cnt - (v0 - 1)
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	n = int(input())
	li = [int(i) for i in input().split()]
	d = {}
	mx = 0
	ctr = 0
	for i in li:
		d[i] = d.get(i, 0) + 1
		if d[i] > mx:
			mx = d[i]
			ctr = 1
		elif d[i] == mx:
			ctr += 1
	if ctr == 1:
		print(int((n - 1 - ctr - (mx - 2)) / (mx - 1)))
	else:
		print(int((n - 1 - ctr - (mx - 2)) / (mx - 1)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = max(a)
	cnts = [0] * (m + 1)
	for i in range(n):
		cnts[a[i]] += 1
	cnts.sort()
	j = m
	while j >= 0 and cnts[j] == cnts[-1]:
		j -= 1
	print((n - (m - j)) // (cnts[-1] - 1) - 1)


import collections
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c = collections.Counter(arr)
	c = collections.Counter(c.values())
	v = max(c)
	print((n - c[v]) // (v - 1) - 1)


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	n = II()
	a = LI()
	if len(set(a)) == 1:
		print(0)
	else:
		d = [0] * (10 ** 5 + 1)
		m = 0
		for i in a:
			d[i] += 1
			m = max(m, d[i])
		if m == 2:
			print(len(set(a)) - 1)
		else:
			s = d.count(m)
			n -= s * m
			print(n // (m - 1) + s - 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = {}
	for i in a:
		if i in b:
			b[i] += 1
		else:
			b[i] = 1
	c = sorted(b.items(), key=lambda x: x[1], reverse=True)
	(u, v) = c[0]
	p = 1
	for i in range(1, len(c)):
		(s, t) = c[i]
		if t == v:
			p += 1
		else:
			break
	n -= p
	n = n // (v - 1)
	print(n - 1)


from sys import stdin
t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	mp = {}
	num = [int(n) for n in input().split()]
	max1 = 0
	for i in num:
		mp[i] = mp.get(i, 0) + 1
		if mp[i] > max1:
			max1 = mp[i]
	maxfreq = [k for (k, v) in mp.items() if int(v) == max1]
	maxfreq1 = len(maxfreq)
	print(int((n - maxfreq1) / (max1 - 1)) - 1)


from collections import *
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().strip().split()))
	c = Counter(a)
	maxm = c.most_common(1)[0][1]
	curr = c.most_common(1)[0][0]
	del c[curr]
	ans = maxm
	gap = 0
	for i in c:
		if c.get(i) >= maxm - 1:
			ans += c.get(i)
			gap += 1
	ans = n - ans
	gap += ans // (maxm - 1)
	print(gap)


t = int(input())
for j in range(1, t + 1):
	n = int(input())
	a_l = map(int, input().split())
	a_d = {}
	for a in a_l:
		if a in a_d.keys():
			a_d[a] = a_d[a] + 1
		else:
			a_d[a] = 1
	a_count_d = {}
	a_values_l = list(a_d.values())
	for a in a_values_l:
		if a in a_count_d.keys():
			a_count_d[a] = a_count_d[a] + 1
		else:
			a_count_d[a] = 1
	M = max(list(a_count_d.keys()))
	teller = a_count_d[M] - 1
	teller_help = 0
	for i in range(1, M):
		teller_help = teller_help + (M - i) * a_count_d.get(M - i, 0)
	teller_help = int(teller_help / (M - 1))
	print(teller + teller_help)


import sys, heapq, copy
from collections import deque
input = sys.stdin.buffer.readline
T = int(input())
for testcase in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = []
	tmp = 1
	for i in range(1, n):
		if a[i] != a[i - 1]:
			c.append(-tmp)
			tmp = 1
		else:
			tmp += 1
	c.append(-tmp)
	heapq.heapify(c)
	if -c[0] == n:
		print(0)
		continue
	ok = 1
	ng = n
	while ng - ok > 1:
		m = (ok + ng) // 2
		if len(c) < m:
			ng = m
			continue
		d = copy.deepcopy(c)
		tank = deque([])
		for i in range(m):
			tank.append(heapq.heappop(d))
		flag = True
		for i in range(m, n):
			r = tank.popleft()
			if r != -1:
				heapq.heappush(d, r + 1)
			if d:
				tank.append(heapq.heappop(d))
			else:
				flag = False
				break
		if flag:
			ok = m
		else:
			ng = m
	print(ok - 1)


import sys
input = sys.stdin.readline
import collections

def countstrs(s):
	return [(k, len(list(g))) for (k, g) in itertools.groupby(s)]
import itertools
q = int(input())
for _ in range(q):
	n = int(input())
	dat = list(map(int, input().split()))
	dat.sort()
	l = countstrs(dat)
	c = collections.Counter(dat)
	maxnum = c.most_common(1)[0][1]
	uniqnum = 0
	for i in range(len(l)):
		(a, b) = l[i]
		if b == maxnum:
			uniqnum += 1
	othernum = n - uniqnum * maxnum
	res = uniqnum - 1 + othernum // (maxnum - 1)
	print(res)


def process(A):
	d = {}
	my_max = [0, 0]
	n = len(A)
	for x in A:
		if x not in d:
			d[x] = 0
		d[x] += 1
		if d[x] > my_max[0]:
			my_max = [d[x], 1]
		elif d[x] == my_max[0]:
			my_max[1] += 1
	(m, c) = my_max
	k1 = (n - c * m) // (m - 1)
	return k1 + c - 1
t = int(input())
for i in range(t):
	n = int(input())
	A = [int(x) for x in input().split()]
	print(process(A))


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * (n + 1)
	for x in a:
		cnt[x] += 1
	m = max(cnt)
	c = cnt.count(m)
	print((n - m * c) // (m - 1) + c - 1)


from sys import stdin
import collections
import math
t = int(stdin.readline().strip())
for _ in range(t):
	n = int(stdin.readline().strip())
	A = list(map(int, stdin.readline().strip().split(' ')))
	A_max_count = 0
	counts = collections.defaultdict(int)
	for a in A:
		counts[a] += 1
		if counts[a] > A_max_count:
			A_max_count = counts[a]
	A_max_rep_of_max_count = 0
	for count in counts.values():
		if count == A_max_count:
			A_max_rep_of_max_count += 1

	def possible(dist):
		max_count = int(math.ceil(n / (dist + 1)))
		max_rep_of_max_count = n % (dist + 1)
		if max_rep_of_max_count == 0:
			max_rep_of_max_count = dist + 1
		if max_count == A_max_count:
			return max_rep_of_max_count >= A_max_rep_of_max_count
		else:
			return max_count > A_max_count
	lo = 0
	hi = n - 1
	while lo + 1 < hi:
		mid = int((lo + hi) // 2)
		if possible(mid):
			lo = mid
		else:
			hi = mid
	print(lo)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import deque as que, defaultdict as vector, Counter
from bisect import bisect as bsearch
from heapq import *
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
inst = lambda : input().decode().rstrip('\n\r')
INF = float('inf')
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	if len(set(a)) == 1:
		print(0)
	else:
		c = Counter(a)
		k = max(c.values())
		eq = 0
		sm = 0
		for i in c:
			if c[i] != k:
				sm += c[i]
			else:
				eq += 1
		k -= 1
		print(eq - 1 + sm // k)


from collections import defaultdict
t = int(input())
for _ in range(t):
	di = defaultdict(lambda : 0)
	l = int(input())
	n = list(map(int, input().split()))
	for ni in n:
		di[ni] += 1
	mv = max(di.values())
	values = sorted(di.values(), reverse=True)
	curr = 0
	answer = -1
	done = False
	for i in range(len(values)):
		if values[i] != mv and (not done):
			mv = max(1, mv - 1)
			done = True
		curr += values[i]
		if curr // mv >= 1:
			answer += 1
			curr %= mv
	print(answer)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
from collections import Counter
for case in range(1, itg() + 1):
	n = itg()
	c = Counter(mpint())
	most_common = c.most_common()
	most = most_common[0][1]
	most_num = 0
	for (k, v) in most_common:
		if v == most:
			most_num += 1
		else:
			break
	interval = (n - most * most_num) // (most - 1)
	ans = most_num - 1 + interval
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = []
	counter = 1
	i = 1
	while i < n:
		if a[i] == a[i - 1]:
			counter += 1
		else:
			k.append(counter)
			counter = 1
		i += 1
	k.append(counter)
	m = max(k)
	kount = k.count(m)
	print(max(0, (n - m - (kount - 1)) // (m - 1)))


from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	lst = [int(ele) for ele in input().split()]
	freq = Counter(lst)
	vals = list(freq.values())
	maxval = max(vals)
	count = 0
	for ele in vals:
		if ele == maxval:
			count += 1
	print((n - count) // (maxval - 1) - 1)


import sys
sys.setrecursionlimit(10000)
from collections import OrderedDict
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mydict = {}
	maximum = 1
	for i in a:
		if i in mydict:
			mydict[i] += 1
			if mydict[i] > maximum:
				maximum = mydict[i]
		else:
			mydict[i] = 1
	no_max = 0
	for (i, k) in mydict.items():
		if k == maximum:
			no_max += 1
	ans = (n - maximum - no_max + 1) // (maximum - 1)
	print(ans)


import sys
input = sys.stdin.readline
from collections import defaultdict
import heapq
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = defaultdict(int)
	for i in a:
		d[i] += 1
	q = []
	for k in d:
		q.append(d[k])
	mx = max(q)
	ct1 = q.count(mx)
	ct2 = q.count(mx - 1)
	ans = ct1 + ct2 - 1
	s = sum(q) - ct1 * mx - ct2 * (mx - 1)
	if s > 0:
		ans += s // (mx - 1)
	print(ans)


from collections import Counter
import math
testCases = int(input())
for _ in range(testCases):
	n = int(input())
	ar = list(map(int, input().split()))
	cntr = dict(Counter(ar))
	cntr = Counter(cntr.values())
	mn = float('inf')
	for x in cntr:
		if x != 1:
			mn = min(mn, int(math.floor((n - cntr[x]) / (x - 1))) - 1)
	print(mn)


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, A):
	freq = Counter(A)
	maxFreq = max(freq.values())
	assert maxFreq > 1
	numMax = sum((1 for v in freq.values() if v == maxFreq))
	if maxFreq == 2:
		return N - 2 * numMax + numMax - 1
	chunkSize = (N - numMax) // (maxFreq - 1)
	return chunkSize - 1
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
TC = int(input())
for tc in range(1, TC + 1):
	(N,) = [int(x) for x in input().split()]
	A = [int(x) for x in input().split()]
	ans = solve(N, A)
	print(ans)


from collections import defaultdict
T = int(input())
for _ in range(T):
	N = int(input())
	a = [int(x) for x in input().split(' ')]
	freq = defaultdict(int)
	for x in a:
		freq[x] += 1
	x = max(freq.values())
	f = sum((y == x for (_, y) in freq.items()))
	print((N - 1 - (f - 1) * x) // (x - 1) + f - 2)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	max3 = 1
	max2 = 1
	w = 0
	c = []
	for i in range(n):
		if i == n - 1:
			c.append(max3)
			if max3 > max2:
				max2 = max3
		elif a[i] == a[i + 1]:
			max3 = max3 + 1
		else:
			c.append(max3)
			if max3 > max2:
				max2 = max3
			max3 = 1
	for i in range(len(c)):
		if max2 == c[i]:
			w = w + 1
	if len(a) - max2 - w + 1 == 0:
		print(0)
	else:
		print((len(a) - max2 - w + 1) // (max2 - 1))


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	n = ri()
	aa = rl()
	cnt = Counter(aa)
	maxi = max(cnt.values())
	nb = 0
	for key in cnt:
		if cnt[key] == maxi:
			nb += 1
	ans = (n - nb) // (maxi - 1) - 1
	print(ans)


for i in range(int(input())):
	n = int(input())
	lis = list(map(int, input().split()))
	f = {}
	for i in lis:
		if i not in f:
			f[i] = 0
		f[i] += 1
	num = []
	for key in f:
		num.append(f[key])
	c = num.count(max(num))
	ans = (n - max(num) - c + 1) // (max(num) - 1)
	print(ans)


import sys, random, bisect, math
input = sys.stdin.readline
mv = 10 ** 5
T = int(input())
for _ in range(T):
	n = int(input())
	A = list(map(int, input().split()))
	G = [0 for i in range(mv + 1)]
	B = [0 for i in range(mv + 1)]
	for i in A:
		B[i] = B[i] + 1
	for i in B:
		if i != 0:
			G[i] = G[i] + 1
	v = max(B)
	gap = G[v] - 1
	tv = n - G[v] * v
	gap = gap + tv // (v - 1)
	print(gap)


from collections import Counter
import sys
input = sys.stdin.readline
T = int(input())
for t in range(T):
	N = int(input())
	A = [int(_) for _ in input().split()]
	cc = Counter(A)
	mc = cc.most_common()
	vm = mc[0][1]
	nb = 0
	for (_, c) in mc:
		if c != vm:
			break
		nb += 1
	nbc = nb * vm
	left = N - nbc
	spaces = vm - 1
	min_blank = left // spaces
	print(min_blank + nb - 1)


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	power = [1]
	for i in range(1, 5000):
		power.append(power[-1] * 2 % mod)
	for _ in range(ii()):
		n = ii()
		a = li()
		a.sort()
		x = []
		c = 1
		for i in range(1, n):
			if a[i] != a[i - 1]:
				x.append(c)
				c = 0
			c += 1
		x.append(c)
		x.sort(reverse=True)

		def can(d):
			cnt_cakes = n // d
			if x[0] > cnt_cakes + 1:
				return False
			i = 0
			distinct_felling = 0
			while i < len(x) and x[i] > cnt_cakes:
				i += 1
				distinct_felling += 1
			return distinct_felling <= n % d
		l = 1
		r = n
		while l <= r:
			m = l + (r - l) // 2
			if can(m):
				ans = m
				l = m + 1
			else:
				r = m - 1
		print(ans - 1)
if file:
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = [0] * (n + 1)
	for i in range(n):
		c[a[i]] += 1
	k = max(c)
	m = c.count(k)
	a.sort()
	print(max(0, (n - m) // (k - 1) - 1))


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	a = 0
	b = 0
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
		if d[i] > a:
			a = d[i]
			b = 1
		elif d[i] == a:
			b += 1
	ans = (n - b * a) // (a - 1) + b - 1
	print(ans)


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for j in a:
		d[j] = d.get(j, 0) + 1
	ma = max(list(d.values()))
	ans = n - ma + 1
	for j in d:
		if d[j] == ma:
			ans -= 1
	print(ans // (ma - 1))


import sys
RI = lambda : [int(x) for x in sys.stdin.readline().strip().split()]
rw = lambda : sys.stdin.readline().strip().split()
ri = lambda : int(sys.stdin.readline().strip())
rs = lambda : sys.stdin.readline().strip()
from collections import defaultdict as df
from math import *
t = ri()
for _ in range(t):
	n = ri()
	l = RI()
	d = df(int)
	for i in l:
		d[i] += 1
	maxo = max(d.values())
	cnt = 0
	for i in d:
		if d[i] == maxo:
			cnt += 1
	rem = n - cnt * maxo
	ans = rem // (maxo - 1)
	print(ans + cnt - 1)


import sys
inputlines = sys.stdin.readlines()
number_of_testcases = int(inputlines[0])
for i in range(number_of_testcases):
	number_of_integers = int(inputlines[2 * i + 1])
	integers = list(map(int, inputlines[2 * i + 2].split(' ')))
	numbers_dict = {}
	for i in integers:
		if i in numbers_dict:
			numbers_dict[i] += 1
		else:
			numbers_dict[i] = 1
	max_freq = max(numbers_dict.values())
	number_of_max_freq_integers = 0
	for (key, value) in numbers_dict.items():
		if value == max_freq:
			number_of_max_freq_integers += 1
	min_distance = (number_of_integers - 1) // (max_freq - 1) - 1
	permissible_numbers = (number_of_integers - 1) % (max_freq - 1)
	while permissible_numbers < number_of_max_freq_integers - 1:
		permissible_numbers = number_of_integers - min_distance * (max_freq - 1) - 1
		min_distance -= 1
	print(min_distance)


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	freq = {}
	for elem in a:
		if elem not in freq:
			freq[elem] = 0
		freq[elem] += 1
	max_val = max((freq[key] for key in freq))
	counter = sum((1 for x in freq if freq[x] == max_val))
	print((n - counter) // (max_val - 1) - 1)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	m = defaultdict(int)
	j = defaultdict(int)
	a = list(map(int, input().split()))
	for i in a:
		m[i] += 1
	maxi = 0
	for l in m:
		maxi = max(maxi, m[l])
		j[m[l]] += 1
	if maxi == 1:
		print(n - 1)
	else:
		ans = j[maxi] - 1
		ans += (n - maxi * j[maxi]) // (maxi - 1)
		print(ans)


import sys
import math as mt
import bisect
from collections import Counter, deque
from heapq import heappush, heappop
input = sys.stdin.readline
t = int(input())
mod = 998244353

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def check(x):
	c = Counter(l)
	que = []
	l1 = deque()
	for (val, cnt) in c.items():
		heappush(que, (-cnt, val))
	while que:
		(cnt, val) = heappop(que)
		cnt = -cnt
		cnt -= 1
		l1.append((cnt, val))
		if len(l1) >= x:
			(cnt, val) = l1.popleft()
			if cnt:
				heappush(que, (-cnt, val))
	for (cnt, val) in l1:
		if cnt:
			return False
	return True
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	r = n
	le = 0
	ans = 0
	while r - le > 1:
		mid = (le + r) // 2
		if check(mid):
			le = mid
		else:
			r = mid
	print(le - 1)


import sys
from collections import Counter
input = sys.stdin.readline

def check(num):
	new = 0
	temp = []
	for i in arr:
		temp.append(i[0])
	prev = 0
	k = ones
	while True:
		count = 0
		for i in range(len(arr)):
			if count <= num and temp[i] > 0:
				new += 1
				count += 1
				temp[i] -= 1
			else:
				break
		temp.sort(reverse=True)
		if new != n:
			if count <= num:
				k -= num - count + 1
			if k < 0:
				return False
			new += num - count + 1
		if temp[0] <= 1:
			return True
for nt in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = Counter(a)
	arr = []
	ones = 0
	for i in c:
		if c[i] == 1:
			ones += 1
			continue
		arr.append((c[i], i))
	arr.sort(reverse=True)
	low = 0
	high = n
	while low < high:
		mid = (low + high) // 2
		if check(mid):
			low = mid + 1
		else:
			high = mid - 1
	if check(low):
		print(low)
	else:
		print(low - 1)


import heapq
import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	mx = 0
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
		mx = max(mx, d[i])
	maxc = 0
	for i in d:
		if d[i] == mx:
			maxc += 1
	rest = n - maxc * mx
	fill = rest // (mx - 1)
	print(maxc - 1 + fill)


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
from collections import deque as que, defaultdict as vector, Counter
from bisect import bisect as bsearch
from heapq import *
inin = lambda : int(input())
inar = lambda : list(map(int, input().split()))
inst = lambda : input().decode().rstrip('\n\r')
INF = float('inf')
_T_ = inin()
for _t_ in range(_T_):
	n = inin()
	a = inar()
	if len(set(a)) == 1:
		print(0)
	else:
		c = Counter(a)
		k = max(c.values())
		eq = 0
		sm = 0
		for i in c:
			if c[i] != k:
				sm += c[i]
			else:
				eq += 1
		k -= 1
		print(eq - 1 + sm // k)


t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ans = 0
	d = {}
	for i in range(n):
		if l[i] in d:
			d[l[i]] += 1
		else:
			d[l[i]] = 1
	maxval = max(d, key=d.get)
	a = 0
	b = 0
	for i in d.values():
		if i == d[maxval]:
			a += 1
		else:
			b += i
	a -= 1
	ans = a + b // (d[maxval] - 1)
	print(ans)


from collections import *
a = int(input())
for i in range(a):
	s = int(input())
	z = list(map(int, input().split()))
	z.sort()
	ans = []
	count = 1
	for i in range(1, len(z)):
		if z[i] == z[i - 1]:
			count += 1
		else:
			ans.append(count)
			count = 1
	ans.append(count)
	ans.sort(reverse=True)
	l = 0
	r = len(z) - 1
	al = defaultdict(int)
	dl = defaultdict(int)
	while l <= r:
		flag = 1
		mid = (l + r) // 2
		if al[mid] == 1:
			break
		else:
			al[mid] = 1
		ele = mid + 1
		s = max(ans)
		m = ans.count(s)
		if ele * (s - 1) >= len(z):
			flag = 0
		elif ele * (s - 1) + m - 1 >= len(z):
			flag = 0
		else:
			flag = 1
		if flag == 1:
			dl[mid] = 1
			l = mid + 1
		else:
			r = mid - 1
	maxa = 0
	for i in dl:
		maxa = max(maxa, i)
	print(max(maxa, 0))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)

def toord(c):
	return ord(c) - ord('a')

def lcm(a, b):
	return a * b // lcm(a, b)
mod = 998244353
INF = float('inf')
from math import factorial, sqrt, ceil, floor, gcd
from collections import Counter, defaultdict, deque
from heapq import heapify, heappop, heappush

def main():
	for _ in range(N()):
		n = N()
		arr = RLL()
		ct = Counter(arr)
		mx = max(ct.values())
		num = 0
		for i in ct:
			if ct[i] == mx:
				num += 1
		print((n - mx * num) // (mx - 1) + num - 1)
main()


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop, heapify
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
from itertools import accumulate
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	l = li()
	cnt = Counter(l)
	l = sorted(cnt, key=lambda x: -cnt[x])
	if cnt[l[0]] == 2:
		print(len(cnt) - 1)
		continue
	l = deque(l)
	finans = 0
	l1 = []
	last = 0
	hell = 0
	temp = 10 ** 5 * cnt[l[0]]
	for i in l:
		curr = [last, hell]
		for j in range(cnt[i]):
			l1.append([last + hell, i])
			hell += 10 ** 5
			if cnt[i] == cnt[l[0]] and hell >= temp:
				hell = 0
				last += 1
			elif cnt[i] < cnt[l[0]] and hell >= temp - 10 ** 5:
				hell = 0
				last += 1
	l1.sort()
	l1 = [i[1] for i in l1]
	m = {}
	ans = float('inf')
	for i in range(len(l1)):
		if l1[i] in m:
			ans = min(ans, i - m[l1[i]] - 1)
		m[l1[i]] = i
	print(ans + finans)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().strip().split()))
	arr = [0] * n
	for i in a:
		arr[i - 1] += 1
	maxi = max(arr)
	if maxi > 2:
		co = arr.count(maxi)
		aka = n - co + 1
		print((aka - 1) // (maxi - 1) - 1)
	else:
		co = arr.count(2)
		print(n - co - 1)


for _ in range(int(input())):
	n = int(input())
	a = [0 for i in range(n + 1)]
	b = list(map(int, input().split()))
	for i in b:
		a[i] += 1
	a.sort()
	k = a[n] - 1
	sum = 0
	for i in range(n - 1, 0, -1):
		sum += min(a[i], k)
	print(sum // k)


t = int(input())
import math
while t > 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	d = {}
	for i in a:
		d[i] = d.get(i, 0) + 1
	m = max(d.values())
	num = 0
	for i in d:
		if d[i] == m:
			num += 1
	left = n - num * m
	ans = left // (m - 1) + (num - 1)
	print(ans)


t = int(input())
for z in range(t):
	n = int(input())
	chisla = {}
	nums = [int(x) for x in input().split()]
	nmax = 0
	maxim = 0
	for x in nums:
		if x not in chisla:
			chisla[x] = 1
		else:
			chisla[x] += 1
	for value in chisla.values():
		if value > maxim:
			maxim = value
			nmax = 1
		elif value == maxim:
			nmax += 1
	print((n - nmax) // (maxim - 1) - 1)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s)
	sys.stdout.write('\n')

def wi(n):
	sys.stdout.write(str(n))
	sys.stdout.write('\n')

def wia(a, sep=' '):
	sys.stdout.write(sep.join([str(x) for x in a]))
	sys.stdout.write('\n')
from collections import Counter
from itertools import permutations
from random import randrange

def solve_naive(n, a):
	ans = 0
	for b in permutations(a):
		best = n
		for i in range(n):
			for j in range(i + 1, n):
				if b[i] == b[j]:
					best = min(best, j - i - 1)
		ans = max(ans, best)
	return ans

def solve(n, a):
	c = Counter(a)
	cnt = c.most_common()[0][1]
	rep = sum([1 for (k, v) in c.items() if v == cnt])
	return (n - rep) // (cnt - 1) - 1
	c = Counter(a)
	b = c.most_common()
	m = len(b)
	lo = n
	idx = 0
	prev = {}
	bb = b.copy()
	while len(bb) > 0:
		for i in range(len(bb)):
			(k, v) = bb[i]
			if k in prev:
				lo = min(lo, idx - prev[k] - 1)
			prev[k] = idx
			bb[i] = (k, v - 1)
			idx += 1
		while len(bb) > 0 and bb[-1][1] == 0:
			bb.pop()
	hi = n
	while hi > lo + 1:
		mid = (lo + hi) // 2
		can = True
		s = set([i for i in range(n)])
		for i in range(m):
			if not can:
				break
			idx = next(iter(s))
			for j in range(b[i][1]):
				if idx >= n:
					can = False
					break
				s.remove(idx)
				idx += mid + 1
		if can:
			lo = mid
		else:
			hi = mid
	return lo

def gen():
	for n in range(2, 9):
		for k in range(1, n + 1):
			for t in range(30):
				a = [randrange(k) + 1 for _ in range(n)]
				if Counter(a).most_common(1)[0][1] < 2:
					continue
				res1 = solve(n, a)
				res2 = solve_naive(n, a)
				if res1 != res2:
					wi(n)
					wia([res1, res2])
					wia(a)
					return

def main():
	for _ in range(ri()):
		n = ri()
		a = ria()
		wi(solve(n, a))
main()


from collections import Counter
T = int(input())
for test in range(T):
	n = int(input())
	a = [int(x) for x in input().split()]
	c = Counter(a).most_common()
	val = c[0][1]
	i = 0
	while i < len(c) and c[i][1] == val:
		i += 1
	i -= 1
	largest = (n - val - i) // (val - 1)
	print(largest)


t = int(input())
for _ in range(t):
	n = int(input())
	freq = [0] * (n + 1)
	arr = list(map(int, input().split()))
	for i in range(n):
		freq[arr[i]] += 1
	modalf = max(freq)
	modes = []
	for i in range(n + 1):
		if freq[i] == modalf:
			modes.append(i)
	print((n - modalf * len(modes)) // (modalf - 1) + len(modes) - 1)


import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *
from heapq import *
from math import *
from itertools import permutations

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')

def inc(d, c):
	d[c] = d[c] + 1 if c in d else 1

def li():
	return [int(xx) for xx in input().split()]

def fli():
	return [float(x) for x in input().split()]

def comp(a, b):
	if a > b:
		return 2
	return 2 if a == b else 0

def gi():
	return [xx for xx in input().split()]

def fi():
	return int(input())

def pro(a):
	return reduce(lambda a, b: a * b, a)

def swap(a, i, j):
	(a[i], a[j]) = (a[j], a[i])

def si():
	return list(input().rstrip())

def mi():
	return map(int, input().split())

def gh():
	sys.stdout.flush()

def isvalid(i, j):
	return 0 <= i < n and 0 <= j < n

def graph(n, m):
	for i in range(m):
		(x, y) = mi()
		a[x].append(y)
		a[y].append(x)

def bo(i):
	return ord(i) - ord('a')

def ck(x, y):
	return int(bin(x)[2:] + bin(y)[2:], 2)
t = fi()
y = [0 for i in range(10 ** 5 + 1)]
while t > 0:
	t -= 1
	n = fi()
	a = li()
	for i in a:
		y[i] += 1
	l = []
	for i in range(n):
		l.append((y[a[i]], a[i]))
	l = list(set(l))
	l.sort(reverse=True)
	a = []
	for i in l:
		a.append(i[1])
	m = len(a)

	def can(mid):
		p = [0 for i in range(n)]
		if mid == 0:
			return True
		c = 0
		k = 0
		for j in range(m):
			pp = y[a[j]]
			for l in range(k, n, mid):
				if pp == 0:
					c += 1
				p[l] = a[j]
				pp -= 1
				if l == k:
					while k < n and p[k] != 0:
						k += 1
			if c >= pp:
				c -= pp
				pp = 0
			if pp > 0:
				return False
		return True
	l = 0
	r = n
	ans = 0
	while l <= r:
		mid = l + (r - l) // 2
		if can(mid):
			ans = max(ans, mid - 1)
			l = mid + 1
		else:
			r = mid - 1
	print(ans)
	for i in a:
		y[i] = 0


test = int(input())
for _ in range(test):
	n = int(input())
	arr = list(map(int, input().split()))
	freq = {}
	maxf = 0
	maxv = -1
	for i in range(n):
		freq[arr[i]] = freq.get(arr[i], 0) + 1
		if freq[arr[i]] > maxf:
			maxf = freq[arr[i]]
			maxv = arr[i]
	ex = 0
	pad = 0
	for (k, v) in freq.items():
		if v < maxf:
			ex += v
		if v == maxf and k != maxv:
			pad += 1
	sp = maxf - 1
	req = ex // sp
	print(req + pad)


t = int(input())
cnt = [0] * 100001
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	e = 0
	mx = 0
	cnt = [0 for __ in range(n + 1)]
	for i in range(n):
		cnt[l[i]] += 1
		if mx < cnt[l[i]]:
			mx = cnt[l[i]]
			e = 1
		elif mx == cnt[l[i]]:
			e += 1
	print((n - e) // (mx - 1) - 1)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = Counter(l)
	c = max(d.values())
	count = 0
	for i in d:
		if d[i] == c:
			count += 1
	count -= 1
	print((n - count - c) // (c - 1))


import sys
input = sys.stdin.readline

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input().strip()

def listStr():
	return list(input().strip())
import collections as col
import math

def solve():
	N = getInt()
	A = getInts()
	counts = col.defaultdict(int)
	best = 0
	for a in A:
		counts[a] += 1
		best = max(best, counts[a])
	tmp = 0
	best_set = set()
	arr = []
	for (key, val) in counts.items():
		if val == best:
			tmp += 1
			best_set.add(key)
		else:
			arr.append((val, key))
	ans = best * [tmp]
	arr.sort(reverse=True)
	j = 0
	for (b, a) in arr:
		for B in range(b):
			ans[j] += 1
			j += 1
			j %= best - 1
	return ans[-2] - 1
for _ in range(getInt()):
	print(solve())


from collections import defaultdict
cases = int(input())
for case in range(cases):
	n = int(input())
	cakes = input().split()
	count = defaultdict(int)
	for cake in cakes:
		count[cake] += 1
	x = defaultdict(int)
	for cake in count:
		x[count[cake]] += 1
	a = max(x)
	b = x[a]
	c = a * b
	rest = n - c
	d = rest / (a - 1)
	print(b + int(d) - 1)


T = int(input())
from collections import defaultdict

def smax(a, b):
	if a > b:
		return a
	else:
		return b
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	D = defaultdict(int)
	for i in range(N):
		D[A[i]] += 1
	max_num = 0
	for key in D:
		max_num = smax(D[key], max_num)
	count = 0
	for key in D:
		if D[key] >= max_num:
			count += 1
	print((N - count * max_num) // (max_num - 1) + count - 1)


import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
input = sys.stdin.readline
getS = lambda : input().strip()
getN = lambda : int(input())
getList = lambda : list(map(int, input().split()))
getZList = lambda : [int(x) - 1 for x in input().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
divide = lambda x: pow(x, MOD - 2, MOD)

def nck(n, k, kaijyo):
	return npk(n, k, kaijyo) * divide(kaijyo[k]) % MOD

def npk(n, k, kaijyo):
	if k == 0 or k == n:
		return n % MOD
	return kaijyo[n] * divide(kaijyo[n - k]) % MOD

def fact_and_inv(SIZE):
	inv = [0] * SIZE
	fac = [0] * SIZE
	finv = [0] * SIZE
	inv[1] = 1
	fac[0] = fac[1] = 1
	finv[0] = finv[1] = 1
	for i in range(2, SIZE):
		inv[i] = MOD - MOD // i * inv[MOD % i] % MOD
		fac[i] = fac[i - 1] * i % MOD
		finv[i] = finv[i - 1] * inv[i] % MOD
	return (fac, finv)

def renritsu(A, Y):
	A = np.matrix(A)
	Y = np.matrix(Y)
	Y = np.reshape(Y, (-1, 1))
	X = np.linalg.solve(A, Y)
	return X.flatten().tolist()[0]

class TwoDimGrid:

	def __init__(self, h, w, wall='#'):
		self.h = h
		self.w = w
		self.size = (h + 2) * (w + 2)
		self.wall = wall
		self.get_grid()

	def get_grid(self):
		grid = [self.wall * (self.w + 2)]
		for i in range(self.h):
			grid.append(self.wall + getS() + self.wall)
		grid.append(self.wall * (self.w + 2))
		self.grid = grid

	def init_cost(self):
		self.cost = [INF] * self.size

	def pos(self, x, y):
		return y * (self.w + 2) + x

	def getgrid(self, x, y):
		return self.grid[y][x]

	def get(self, x, y):
		return self.cost[self.pos(x, y)]

	def set(self, x, y, v):
		self.cost[self.pos(x, y)] = v
		return

	def show(self):
		for i in range(self.h + 2):
			print(self.cost[(self.w + 2) * i:(self.w + 2) * (i + 1)])

	def showsome(self, tgt):
		for t in tgt:
			print(t)
		return

	def showsomejoin(self, tgt):
		for t in tgt:
			print(''.join(t))
		return

	def search(self):
		grid = self.grid
		move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
		move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]

def judge(mid, cnt, n):
	xx = cnt[0]
	if (mid + 1) * (xx - 1) >= n:
		return False
	elif (mid + 1) * xx <= n:
		return True
	yoyu = n % (mid + 1)
	if Counter(cnt)[xx] <= yoyu:
		return True
	else:
		return False

def solve():
	n = getN()
	nums = getList()
	cnt = list(Counter(nums).values())
	cnt.sort(reverse=True)
	mn = 0
	mx = n
	while mx - mn > 1:
		mid = (mx + mn) // 2
		if judge(mid, cnt, n):
			mn = mid
		else:
			mx = mid
	if judge(mx, cnt, n):
		print(mx)
	else:
		print(mn)

def main():
	n = getN()
	for _ in range(n):
		solve()
	return
main()


from collections import defaultdict
t = int(input())
while t != 0:
	n = int(input())
	list1 = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		d[list1[i]] += 1
	c = 0
	maxi = 0
	for i in d.keys():
		if d[i] > 1:
			maxi = max(d[i], maxi)
	for i in d.keys():
		if d[i] == maxi:
			c += 1
	if c > 1:
		print((n - maxi - (c - 1)) // (maxi - 1))
	else:
		print((n - maxi) // (maxi - 1))
	t -= 1


from sys import stdin, stdout

def pinkie_pie_eas_patty_cakes(n, a_a):
	dic = {}
	mx = 0
	for a in a_a:
		if a not in dic:
			dic[a] = 0
		dic[a] += 1
		mx = max(dic[a], mx)
	cnt = 0
	for k in dic:
		if dic[k] == mx:
			cnt += 1
	res = cnt - 1
	res += (n - cnt * mx) // (mx - 1)
	return res
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	a_a = list(map(int, stdin.readline().split()))
	ans = pinkie_pie_eas_patty_cakes(n, a_a)
	stdout.write(str(ans) + '\n')


import sys, math, cmath, time
from collections import defaultdict
start_time = time.time()

def solve():
	n = inp()
	a = inlt()
	q = counter(a)
	w = q.count(max(q)) - 1
	print((len(a) - w - max(q)) // (max(q) - 1))

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = (q[ord(a[i]) - 97], 1)
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


from collections import *
for _ in range(int(input())):
	n = int(input())
	ai = list(map(int, input().split()))
	count = Counter(ai)
	mostc = count.most_common()
	num = mostc[0][0]
	numcount = mostc[0][1]
	ans = -1
	for num in count:
		if count[num] == numcount:
			count[num] = 0
			ans += 1
	divisions = numcount - 1
	temp = 0
	for i in count.values():
		temp += i
		if temp >= divisions:
			temp -= divisions
			ans += 1
	print(ans)


from collections import Counter
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()

def check(s):
	s -= 1
	(u, c) = (h.copy(), {})
	ans = []
	for i in range(n):
		(val, key) = heappop(u)
		val += 1
		if val:
			c[key] = val
		ans.append(key)
		if i - (s + 1) >= 0 and ans[i - (s + 1)] in c:
			newKey = ans[i - (s + 1)]
			heappush(u, (c[newKey], newKey))
			del c[newKey]
		if len(u) == 0:
			break
	return True if len(ans) == n else False
for _ in range(t):
	(n,) = gil()
	a = gil()
	h = Counter(a)
	h = [(-h[key], key) for key in h]
	heapify(h)
	ans = 0
	(l, r) = (1, n)
	while l <= r:
		mid = (l + r) // 2
		if check(mid):
			l = mid + 1
			ans = mid
		else:
			r = mid - 1
	print(ans)


import heapq
from collections import deque
import sys
input = sys.stdin.readline

def check(mid):
	copy = []
	for i in freq:
		heapq.heappush(copy, -1 * freq[i])
	queue = deque()
	for i in range(n):
		if i >= mid + 1 and len(queue) > 0:
			z = queue[0][1]
			if i - z >= mid + 1:
				(x, z) = queue.popleft()
				heapq.heappush(copy, x)
		if len(copy) == 0:
			return False
		a = heapq.heappop(copy)
		a += 1
		if a != 0:
			queue.append((a, i))
	if len(copy) == 0 and len(queue) == 0:
		return True
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split() if i != '\n']
	freq = dict()
	for i in a:
		if i not in freq:
			freq[i] = 0
		freq[i] += 1
	(lo, hi) = (0, n - 1)
	while lo < hi:
		mid = (lo + hi) // 2
		if check(mid):
			lo = mid + 1
		else:
			hi = mid
	sys.stdout.write(str(hi - 1) + '\n')


def check(m):
	if (mx - 1) * m <= sm - mx - cnt:
		return True
	return False
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	u = []
	k = 1
	for i in range(1, len(a)):
		if a[i] == a[i - 1]:
			k += 1
		else:
			u.append(k)
			k = 1
	u.append(k)
	u.sort()
	sm = sum(u)
	mx = max(u)
	cnt = 0
	for i in range(len(u) - 1):
		if u[i] == mx:
			cnt += 1
	L = 0
	R = n
	while R - L > 1:
		M = (L + R) // 2
		if check(M):
			L = M
		else:
			R = M
	print(L)


import sys, math
import io, os
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
from decimal import Decimal
from fractions import Fraction
INF = float('inf')
mod = int(1000000000.0) + 7
for t in range(int(data())):
	n = int(data())
	a = mdata()
	d = dd(int)
	for i in a:
		d[i] += 1
	m = max(d.values())
	cnt = 0
	for i in d:
		if d[i] == m:
			n -= m
			cnt += 1
	n //= m - 1
	out(n + cnt - 1)


t = int(input())
for test_case in range(1, t + 1):
	n = int(input())
	l = list(map(int, input().split()))
	counts = {}
	for k in l:
		if not k in counts:
			counts[k] = 0
		counts[k] += 1
	(r, a) = (0, 0)
	for (val, count) in counts.items():
		if count > r:
			r = count
			a = 1
		elif count == r:
			a += 1
	print((n - r - a + 1) // (r - 1))


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
from collections import Counter
for _ in range(II()):
	n = II()
	aa = LI()
	ac = Counter(aa)
	mx = max(ac.values())
	cnt = list(ac.values()).count(mx)
	ans = (n - (cnt - 1) - mx) // (mx - 1)
	print(ans)


from sys import stdin
input = stdin.readline
import bisect
import math
for xoxo in range(1):
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		ans = 0
		f = [0] * n
		for i in a:
			f[i - 1] += 1
		m = max(f)
		p = f.count(m)
		if m > math.ceil(n / 2):
			print('0')
		else:
			N = m + n - p * m
			while m + (m - 1) * ans < N:
				ans += 1
			if m + (m - 1) * ans > N:
				print(p - 1 + ans - 1)
			else:
				print(p - 1 + ans)


T = int(input())
for _ in range(T):
	N = int(input())
	arr = [int(x) for x in input().split()]
	d = {}
	M = 0
	for a in arr:
		d[a] = d.get(a, 0) + 1
		M = max(M, d[a])
	n = 0
	for b in d.keys():
		if d[b] == M:
			n += 1
	ans = (N - n * M) // (M - 1) + n - 1
	print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict
from bisect import bisect_left as bl, bisect_right as br
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
t = ip()
for _ in range(t):
	n = ip()
	arr = list(inp())
	dic = Counter(arr)
	val = []
	ch = max(list(dic.values()))
	for i in dic:
		if dic[i] == ch:
			val.append(i)
	freq = len(val)
	ans = (n - freq) // (ch - 1) - 1
	print(ans)


import os, sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import ceil
import heapq
mod = 10 ** 9 + 7
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	for i in a:
		d[i] = d.get(i, 0) + 1
	m = 0
	ct = 0
	id = -1
	for i in d:
		if d[i] > m:
			m = d[i]
			id = i
			ct = 1
		elif d[i] == m:
			ct += 1
	ans = [ct - 1] * (m - 1)
	heapq.heapify(ans)
	for i in d:
		if d[i] != m:
			for j in range(d[i]):
				t = ans[0] + 1
				heapq.heappushpop(ans, t)
	print(ans[0])


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	b = list(map(int, input().split()))
	d = defaultdict(lambda : 0)
	ans = 0
	for j in range(n):
		d[b[j]] += 1
		if d[b[j]] > ans:
			ans = d[b[j]]
			s = b[j]
	b = sorted(list(set(b)))
	res = 0
	j = 0
	while j < len(b):
		if b[j] == s:
			pass
		elif d[b[j]] == ans:
			res += ans - 1
		else:
			res += d[b[j]]
		j += 1
	print(res // (ans - 1))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	dic = {}
	maxx = 0
	for i in arr:
		try:
			dic[i] += 1
			maxx = max(maxx, dic[i])
		except:
			dic[i] = 1
			maxx = max(maxx, dic[i])
	for i in dic:
		if dic[i] == maxx:
			n -= 1
	n += 1
	print((n - maxx) // (maxx - 1))


import heapq
import copy

def copyOnto(freqv, jump, n):
	buff = []
	hp = [(-cnt, k) for (k, cnt) in freqv.items()]
	heapq.heapify(hp)
	for i in range(n):
		if i - jump >= 0 and freqv[buff[i - jump]]:
			heapq.heappush(hp, (-freqv[buff[i - jump]], buff[i - jump]))
		if not hp:
			return False
		(_, t) = heapq.heappop(hp)
		freqv[t] -= 1
		buff.append(t)
	return True

def solve():
	n = int(input())
	arr = [int(v) for v in input().split()]
	cntr = {}
	for v in arr:
		cntr.setdefault(v, 0)
		cntr[v] += 1
	l = 0
	r = n
	while l < r:
		m = l + (r - l) // 2
		if copyOnto(copy.copy(cntr), m, n):
			l = m + 1
		else:
			r = m
	l -= 1
	print(l - 1)
t = int(input())
for _ in range(t):
	solve()


test = int(input())
c = []
for i in range(0, 100005):
	c.append(0)
for t in range(0, test):
	n = int(input())
	for i in range(0, 100005):
		c[i] = 0
	a = [int(i) for i in input().split(' ')]
	a.sort()
	for e in a:
		c[e] += 1
	mm = max(c)
	mmc = c.count(mm)
	s = sum(c) - mm * mmc
	print(s // (mm - 1) + mmc - 1)


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(i) for i in input().split() if i != '\n']
	freq = [0] * (n + 1)
	for i in a:
		freq[i] += 1
	freq.sort(reverse=True)
	(maxfreq, count) = (freq[0], 0)
	for i in freq:
		if i == maxfreq:
			count += 1
	last = n + 1 - count
	diff = (last - 1) // (maxfreq - 1)
	print(diff - 1)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	s = list(map(int, input().split()))
	d = Counter(s)
	d = list(d.items())
	d.sort(reverse=True, key=lambda x: x[1])
	l = len(d)
	now = [1, d[0][1]]
	for i in range(1, l):
		if now[1] == d[i][1]:
			now[0] += 1
		else:
			break
	k = now[1]
	m = now[0]
	print((n - m) // (k - 1) - 1)


import sys, io, os, time
from collections import defaultdict
from collections import OrderedDict
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	q = [0] * max(a)
	for i in range(n):
		q[a[i] - 1] += 1
	w = q.count(max(q)) - 1
	print((len(a) - w - max(q)) // (max(q) - 1))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
import copy
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('../output.txt', 'w')
except:
	pass
for _ in range(L()[0]):
	n = L()[0]
	A = L()
	d = {}
	mx = 0
	for i in range(n):
		d[A[i]] = d.get(A[i], 0) + 1
		mx = max(mx, d[A[i]])
	a = 0
	for k in d:
		if d[k] == mx:
			a += 1
	if mx == 1:
		print(n)
		continue
	if a == 1 and n - mx < mx - 1:
		print(0)
		continue
	print(a - 1 + (n - mx * a) // (mx - 1))


q = int(input())
for i in range(q):
	n = int(input())
	arr = [int(x) for x in input().split()]
	mx = 0
	dic = {}
	flag = 0
	for i in range(n):
		if arr[i] not in dic:
			dic[arr[i]] = 0
		dic[arr[i]] += 1
		mx = max(mx, dic[arr[i]])
	for k in dic.keys():
		if dic[k] == mx:
			flag += 1
	ct = n - flag * mx
	if flag == 1 and ct == 0:
		print(0)
		continue
	if flag == n:
		print(n)
		continue
	if flag >= 1:
		print(flag - 1 + int(ct // (mx - 1)))


from collections import defaultdict as dd
for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = dd(int)
	for i in range(n):
		d[a[i]] += 1
	v = list(d.values())
	m = max(v)
	k = v.count(m)
	print((n - k) // (m - 1) - 1)


from sys import stdin
from collections import deque
import heapq
tt = int(stdin.readline())
for loop in range(tt):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	dic = {}
	for i in a:
		if i not in dic:
			dic[i] = 0
		dic[i] += 1
	l = 0
	r = n
	while r - l != 1:
		m = (l + r) // 2
		q = []
		wait = deque([])
		for i in dic:
			heapq.heappush(q, (-1 * dic[i], i))
		flag = True
		for i in range(n):
			while len(wait) > 0 and wait[0][0] < i - m:
				(last, count, num) = wait.popleft()
				heapq.heappush(q, (count, num))
			if len(q) == 0:
				flag = False
				break
			(count, num) = heapq.heappop(q)
			count += 1
			if count != 0:
				wait.append((i, count, num))
		if flag:
			l = m
		else:
			r = m
	print(l)


from sys import stdin, stdout
import math, queue, heapq
fastinput = stdin.readline
fastout = stdout.write
t = int(fastinput())
while t:
	t -= 1
	n = int(fastinput())
	cnt = [0] * (n + 1)
	for i in fastinput().split():
		cnt[int(i)] += 1
	maxx = max(cnt)
	num = cnt.count(maxx)
	print((n - num) // (maxx - 1) - 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	r = [0] * n
	c = [0] * (max(a) + 1)
	for i in a:
		c[i] += 1
	x = []
	for i in range(len(c)):
		if c[i] != 0:
			x.append([c[i], i])
	x.sort(reverse=True)
	v = x[0][0]
	co = 0
	for i in x:
		if i[0] == v:
			co += 1
	l = n - (co - 1) - 1
	import math
	x = math.ceil(l / (v - 1)) - 1
	if l % (v - 1) == 0:
		print(x)
	else:
		print(l // (v - 1) - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	for i in a:
		if d.get(i, None) == None:
			d[i] = 0
		d[i] += 1
	m = 0
	for (k, v) in d.items():
		m = max(m, v)
		if m == v:
			key = k
	count = 0
	for (k, v) in d.items():
		if v == m:
			count += 1
	count -= 1
	print((n - count - m) // (m - 1))


from sys import stdin
input = stdin.readline

def help():
	dicti = {}
	n = int(input())
	arr = list(map(int, input().split(' ')))
	for i in range(n):
		dicti[arr[i]] = dicti.get(arr[i], 0) + 1
	temp = list(dicti.values())
	maxi = max(temp)
	counti = temp.count(maxi)
	ans = counti - 1
	betweenmin = (n - maxi * counti) // (maxi - 1)
	print(ans + betweenmin)
for _ in range(int(input())):
	help()


import math
while True:
	try:
		T = int(input())
		for _ in range(T):
			n = int(input())
			a = list(map(int, input().split()))
			vis = [0 for i in range(n + 1)]
			maxz = 0
			pos = -1
			for i in range(n):
				vis[a[i]] += 1
				if vis[a[i]] > maxz:
					maxz = vis[a[i]]
					pos = a[i]
			cnt = 0
			for i in range(1, n + 1):
				if vis[i] == maxz:
					cnt += 1
			print((n - maxz * cnt) // (maxz - 1) + cnt - 1)
	except EOFError:
		break


from collections import *
t = int(input())
while t:
	buc = 0
	t -= 1
	n = int(input())
	arr = [int(x) for x in input().split()]
	c = Counter(arr)
	arr = []
	for key in c:
		arr.append([c[key], key])
	arr.sort(reverse=True)
	s = arr[0][0]
	l = [[] for i in range(s)]
	for (value, key) in arr:
		till = value
		while till:
			till -= 1
			l[buc].append(key)
			buc += 1
			if value == s:
				buc %= s
			else:
				buc %= s - 1
	print(len(l[-2]) - 1)


from collections import Counter as C
import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	cnt = C(arr)
	cnt2 = list(cnt.values())
	cnt2.sort(reverse=True)
	mC = cnt2[0]
	for i in range(len(cnt2)):
		if cnt2[i] != mC:
			i -= 1
			break
	i += 1
	res = (n - i) // (mC - 1) - 1
	print(res)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = [0] * (10 ** 5 + 1)
	for i in a:
		c[i] += 1
	k = max(c)
	x = 0
	for i in c:
		if i == k:
			x += 1
	print((n - x - 1 - (k - 2)) // (k - 1))


mod = 998244353
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	l = list()
	for i in d:
		l.append((d[i], i))
	l.sort(reverse=True)
	c = 0
	lim = l[0][0]
	extra = 0
	r = 0
	for i in l:
		if i[0] == lim:
			r += 1
		else:
			extra += i[0]
	if lim == 1:
		print(n)
	else:
		r += extra // (lim - 1)
		print(r - 1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(cnt, vals) = ([0 for _ in range(int(input()) + 1)], [int(i) for i in input().split()])
	for i in vals:
		cnt[i] += 1
	(n, m, c) = (len(vals), max(cnt), cnt.count(max(cnt)))
	print((n - m * c) // (m - 1) + (c - 1))


import sys, math
input = sys.stdin.readline
t = int(input())
for r in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		try:
			d[i] += 1
		except:
			d[i] = 1
	freq = {}
	for i in d:
		try:
			freq[d[i]] += 1
		except:
			freq[d[i]] = 1
	maxFreq = 0
	for i in freq:
		maxFreq = max(maxFreq, i)
	countMaxFreq = freq[maxFreq]
	ans = 0
	for i in range(n):
		if countMaxFreq - 1 + (maxFreq - 1) * (i + 1) <= n - 1:
			ans = i
	print(ans)


import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz'
MOD = 1000000007

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]

def possible(x):
	pos = [-1] * n
	cur = -1
	for (need, i) in C:
		cur += 1
		ind = cur
		for j in range(need):
			try:
				pos[ind] = i
			except:
				return False
			ind += x + 1
	return True
for _ in range(Int()):
	n = Int()
	a = array()
	C = Counter(a)
	C = [(C[i], i) for i in C]
	C.sort(reverse=True)
	low = 0
	high = n - 2
	while low <= high:
		mid = low + (high - low) // 2
		if possible(mid):
			ans = mid
			low = mid + 1
		else:
			high = mid - 1
	print(ans)


t = int(input())
for i in range(0, t):
	n = int(input())
	cakes = list(map(int, input().split(' ')))
	count = [0] * (n + 1)
	for num in cakes:
		count[num] += 1
	count.sort(reverse=True)
	max = count[0]
	result = count.count(max) - 1
	others = sum((num for num in count if num != max))
	result += int(others / (max - 1))
	print(result)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = dict()
	mx = 0
	for i in a:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
		mx = max(mx, d[i])
	maxc = 0
	for i in d.values():
		maxc += i == mx
	left = n - mx * maxc
	ans = left // (mx - 1) + maxc - 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	lis = [0] * n
	for j in range(n):
		lis[arr[j] - 1] += 1
	m = max(lis)
	a = lis.count(m)
	b = -a + n
	c = b - 1
	d = m
	d -= 2
	c -= d
	e = c // (d + 1)
	print(e)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	low = 0
	high = n - 2
	cnt = [0] * (n + 1)
	for i in a:
		cnt[i] += 1
	cnt.sort(reverse=True)
	ans = cnt.count(cnt[0])
	while low < high:
		gap = math.ceil((low + high) / 2)
		if gap * (cnt[0] - 1) + cnt[0] + ans - 1 <= n:
			low = gap
		else:
			high = gap - 1
	print(low)


from collections import Counter as c
for s in [*open(0)][2::2]:
	s = s.split()
	x = c(c(s).values())
	m = max(x)
	print((len(s) - x[m]) // (m - 1) - 1)


def ans(a, n):
	d = {}
	for i in a:
		if i not in d:
			d[i] = 1
		else:
			d[i] += 1
	lis = list(d.values())
	if len(lis) == 1:
		return 0
	maxm = max(lis)
	summ = 0
	for i in lis:
		if i == maxm:
			summ += i - 1
		else:
			summ += i
	summ -= maxm - 1
	return summ // (maxm - 1)
m = int(input())
for i in range(m):
	n = int(input())
	lis = input().split()
	a = []
	for i in lis:
		a.append(int(i))
	print(ans(a, n))


from collections import Counter
t = int(input())
for i in range(t):
	n = int(input())
	a = [int(v) for v in input().split()]
	d = Counter(a)
	m = max(d.values())
	p = 0
	for v in d:
		if d[v] == m:
			p = p + 1
	p = max(0, p - 1)
	res = (n - m - p) // (m - 1)
	print(res)


import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
t = ni()
for _ in range(t):
	n = ni()
	a = nl()
	mmp = [0] * (n + 1)
	maxx = max(a)
	for i in a:
		mmp[i] += 1
	mmp.sort(reverse=True)
	l = 0
	k = mmp[l]
	(sum_k, temp) = (0, 0)
	while mmp[l]:
		if mmp[l] >= k - 1:
			sum_k += 1
		else:
			temp += mmp[l]
		if temp >= k - 1:
			sum_k += temp // (k - 1)
			temp %= k - 1
		l += 1
	print(sum_k - 1)


from sys import stdin, stdout
from collections import Counter
nmbr = lambda : int(stdin.readline())
lst = lambda : list(map(int, stdin.readline().split()))

def fn(diff):
	rem = [0] * n
	p = 0
	n1 = len(l1)
	for i in range(n1):
		while rem[p] != 0:
			p += 1
		if p == n:
			return False
		lim = i + diff * (l1[i] - 1)
		if lim >= n:
			return False
	return True
for _ in range(nmbr()):
	n = nmbr()
	a = lst()
	d = Counter(a)
	l1 = sorted(d.values(), reverse=True)
	l = 0
	r = n
	while l <= r:
		mid = l + r >> 1
		if fn(mid):
			l = mid + 1
		else:
			r = mid - 1
	print(r - 1)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(lambda x: int(x), input().split()))
	hashmap = {}
	maximum = 0
	for i in range(0, len(a)):
		if a[i] not in hashmap:
			hashmap[a[i]] = 0
		hashmap[a[i]] += 1
		if hashmap[a[i]] > maximum:
			maximum = hashmap[a[i]]
	hashmap = sorted(hashmap.items(), key=lambda x: x[1], reverse=True)
	total_max = 0
	for i in range(0, len(hashmap)):
		if hashmap[i][1] == maximum:
			total_max += 1
	answer = (n - total_max * maximum) // (maximum - 2 + 1) + (total_max - 1)
	print(answer)


t = 1
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	data = [0] * (n + 1)
	for i in range(n):
		data[a[i]] += 1
	S = set(a)
	m = len(S)

	def cond(t):
		(q, r) = (n // (t + 1), n % (t + 1))
		if r > m:
			return False
		check = 0
		for i in range(1, n + 1):
			if data[i] > q + 1:
				return False
			elif data[i] == q + 1:
				check += 1
		return r >= check
	ok = 0
	ng = n
	while ng - ok > 1:
		test = (ng + ok) // 2
		if cond(test):
			ok = test
		else:
			ng = test
	print(ok)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())
sys.setrecursionlimit(1500)

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		l = list(In())
		d = {}
		ma = -1
		for x in l:
			if d.get(x, -1) != -1:
				d[x] += 1
				ma = max(d[x], ma)
			else:
				d[x] = 1
				ma = max(d[x], ma)
		mama = 0
		for x in d:
			if d[x] == ma:
				mama += 1
		print(math.floor((n - mama) / (ma - 1)) - 1)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	a.append(999999)
	(rama, add) = ([], 1)
	(maxi, count) = (0, 1)
	for i in range(n):
		if a[i] == a[i + 1]:
			add += 1
		else:
			rama.append(add)
			if add > maxi:
				maxi = add
				count = 0
			if add == maxi:
				count += 1
			add = 1
	m = n - maxi * count
	d = m // (maxi - 1)
	ans = d + count - 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
for _ in range(int(input()) if True else 1):
	n = int(input())
	a = list(map(int, input().split()))
	di = {}
	for i in a:
		di[i] = 1 if i not in di else di[i] + 1
	x = max([di[i] for i in di])
	y = len([k for k in di if di[k] == x])
	print((n - x - y + 1) // (x - 1))


def ispossible(n, count, mid, maxi):
	if maxi + mid * (maxi - 1) + count - 1 > n:
		return False
	else:
		return True

def answer(n, A):
	l = 0
	r = n - 2
	d = {}
	for i in range(len(A)):
		if A[i] in d:
			d[A[i]] += 1
		else:
			d[A[i]] = 1
	maxi = max(list(d.values()))
	count = 0
	for i in d:
		if d[i] == maxi:
			count += 1
	res = -1
	while r >= l:
		mid = (l + r) // 2
		ans = ispossible(n, count, mid, maxi)
		if ans:
			res = mid
			l = mid + 1
		else:
			r = mid - 1
	return res
t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	print(answer(n, arr))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = intIn()
while t > 0:
	t -= 1
	n = intIn()
	a = listIn()
	di = defaultdict(int)
	for i in range(n):
		di[a[i]] += 1
	m = max(di.values())
	cnt = 0
	for ele in di:
		if di[ele] == m:
			cnt += 1
	ans = 1
	while True:
		dist = cnt * m + ans * (m - 1)
		if dist < n:
			ans += 1
		elif dist == n:
			break
		else:
			ans -= 1
			break
	print(ans + cnt - 1)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	(maxcnt, maxval) = (0, 0)
	d = defaultdict(int)
	for i in l:
		d[i] += 1
		if d[i] > maxval:
			maxval = d[i]
			maxcnt = 1
		elif d[i] == maxval:
			maxcnt += 1
	ans = maxcnt - 1 + (n - maxval * maxcnt) // (maxval - 1)
	print(ans)


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
from collections import Counter as cc
(t,) = I()
for _ in range(t):
	(n,) = I()
	l = I()
	an = 0
	d = cc(l)
	ma = max(d.values())
	ct = list(d.values()).count(ma)
	rm = n - ct * ma
	an += ct - 1 + rm // (ma - 1) if ma != 1 else n
	print(an)


from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
import sys

def func(A):
	res = float('-inf')
	(l, h) = (1, len(A) - 2)
	while l <= h:
		N = l + (h - l) // 2
		task_counts = Counter(A).values()
		M = max(task_counts)
		Mct = list(task_counts).count(M)
		temp = (M - 1) * (N + 1) + Mct
		if temp < len(A):
			res = max(res, N)
			l = N + 1
		elif temp == len(A):
			res = max(res, N)
			l = N + 1
		else:
			h = N - 1
	if res == float('-inf'):
		return 0
	return res
t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	print(func(A))


import collections
import sys
output = []
int = int
len = len
str = str
abs = abs
stringOfList = lambda x: [str(i) for i in x]
print = lambda *x: output.append(' '.join(stringOfList(x)))

def solve():
	n = int(input())
	I = list(map(int, input().split()))
	Map = collections.Counter(I)
	MaxCnt = max(list(Map.values()))
	cntMaxCnt = len(list(filter(lambda x: x == MaxCnt, Map.values())))
	for i in Map.keys():
		if Map[i] == MaxCnt:
			Map[i] = 0
	A = [[] for _ in range(MaxCnt - 1)]
	B = sorted(Map.values(), reverse=True)
	j = 0
	for i in range(0, len(B)):
		t = B[i]
		while t:
			A[j].append(0)
			j += 1
			j %= MaxCnt - 1
			t -= 1
	print(len(A[MaxCnt - 2]) + cntMaxCnt - 1)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()
sys.stdout.write('\n'.join(output))


from collections import Counter, defaultdict
for _ in range(int(input())):
	n = int(input())
	a = [*map(int, input().split())]
	c = Counter(a)
	cc = Counter(c.values())
	m = c.most_common()[0][1]
	print((n - cc[m]) // (m - 1) - 1)


from sys import stdin
for testcase in range(int(stdin.readline())):
	n = int(stdin.readline())
	cnt = [0] * (n + 10)
	for i in map(int, stdin.readline().split()):
		cnt[i] += 1
	cnt.sort(reverse=True)
	i = 0
	while i < n and cnt[i] == cnt[0]:
		i += 1
	group = [i - 1] * (cnt[0] - 1)
	cur = 0
	for num in cnt[i:]:
		while num > 0:
			num -= 1
			group[cur] += 1
			cur = (cur + 1) % len(group)
	print(min(group))


import math as mt

def tran(arr):
	arr.sort()
	c = [1]
	cval = [int(arr[0])]
	for i in range(1, len(arr)):
		if arr[i] == arr[i - 1]:
			c[-1] = c[-1] + 1
		else:
			cval.append(int(arr[i]))
			c.append(1)
	cc = list(c)
	c.sort()
	if len(c) == 1:
		return 0
	else:
		c.reverse()
		i = 0
		while i < len(c) - 1:
			if c[i] == c[i + 1]:
				i = i + 1
			else:
				break
		if i == len(c) - 1:
			return i
		elif i == 0:
			return int((len(arr) - c[0]) / (c[0] - 1))
		else:
			s = len(arr) - (i + 1) * c[0]
			return i + int(s / (c[0] - 1))
t = int(input())
ans = []
for i in range(t):
	n = int(input())
	arr = list(map(int, input().rstrip().split()))
	r = tran(arr)
	ans.append(r)
for i in ans:
	print(i)


import sys
input = sys.stdin.readline
from collections import *

def judge(x):
	c = [0] * (M - 1)
	idx = 0
	for (k, v) in cnt.items():
		if k == skip:
			continue
		v = min(v, M - 1)
		for _ in range(v):
			c[idx] += 1
			idx += 1
			idx %= M - 1
	return min(c) >= x

def binary_search():
	(l, r) = (0, n)
	while l <= r:
		m = (l + r) // 2
		if judge(m):
			l = m + 1
		else:
			r = m - 1
	return r
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = Counter(a)
	M = max(list(cnt.values()))
	for (k, v) in cnt.items():
		if v == M:
			skip = k
	print(binary_search())


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	count = Counter(list(map(int, input().split())))
	occurances_count = []
	for key in count:
		occurances_count.append(count[key])
	_max = max(occurances_count)
	counts = occurances_count.count(_max)
	ans = n - _max * counts
	print(ans // (_max - 1) + counts - 1)


for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	count = [0] * (max(a) + 1)
	for i in a:
		count[i] += 1
	m = max(count)
	cnt = count.count(m)
	dis = n - cnt + 1
	print((dis - m) // (m - 1))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	n = int(data())
	arr = l()
	c = C(arr)
	m = max(c.values())
	cons = False
	answer = 0
	cnt = 0
	for i in c.keys():
		if c[i] == m and (not cons):
			cons = True
			continue
		if c[i] == m:
			answer += 1
		else:
			cnt += c[i]
	answer += cnt // (m - 1)
	out(answer)


def main():
	(n,) = map(int, input().split(' '))
	cnt = {}
	for _ in input().split(' '):
		a = int(_)
		if a in cnt:
			cnt[a] += 1
		else:
			cnt[a] = 1
	vals = list(sorted(cnt.values(), reverse=True))
	rep = 0
	while rep < len(vals) and vals[rep] == vals[0]:
		rep += 1
	return (n - rep) // (vals[0] - 1) - 1
for _ in range(int(input())):
	print(main())


def isPos(arr, n, diff):
	di = {}
	for i in arr:
		di[i] = di.get(i, 0) + 1
	liTup = []
	for i in di:
		liTemp = []
		liTemp.append(i)
		liTemp.append(di[i])
		tup = tuple(liTemp)
		liTup.append(tup)
	liTup.sort(key=lambda x: x[1])
	liTup.reverse()
	fill = [-1] * len(arr)
	ctr = 0
	for i in liTup:
		e = i[0]
		f = i[1]
		p = ctr
		smallCtr = 0
		while p < len(arr):
			if smallCtr >= f:
				break
			fill[p] = e
			p += diff
			smallCtr += 1
		ctr += 1
		if smallCtr < f:
			return False
	return True
for _ in range(int(input())):
	n = int(input())
	liStr = input().split()
	arr = []
	for i in liStr:
		arr.append(i)
	s = 0
	e = len(arr) - 1
	ans = 0
	while s <= e:
		mid = (s + e) // 2
		if isPos(arr, n, mid):
			ans = mid
			s = mid + 1
		else:
			e = mid - 1
	print(ans - 1)


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def readTree():
	v = int(input())
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return (adj, v)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return
mod = 10 ** 9 + 7

def solve():
	n = II()
	li = L()
	d = {}
	mx = -1
	for ele in li:
		d[ele] = d.get(ele, 0) + 1
		if d[ele] > mx:
			mx = d[ele]
	cnt = 0
	for ele in d:
		if d[ele] == mx:
			cnt += 1
	left = n - cnt * mx
	print(left // (mx - 1) + cnt - 1)
t = II()
for i in range(t):
	solve()


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	a = inputlist()
	mp = [0] * 100001
	mx = 0
	count = 0
	for i in range(n):
		mp[a[i]] += 1
		if mp[a[i]] > mx:
			mx = mp[a[i]]
			count = 1
		elif mp[a[i]] == mx:
			count += 1
	print((n - mx * count) // (mx - 1) + count - 1)


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
import os
import sys
from io import BytesIO, IOBase

def main():
	pass
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for xyz in range(0, int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = [0] * (max(l) + 1)
	for i in l:
		f[i] += 1
	f.sort(reverse=True)
	if f[0] != f[1]:
		ans = sum(f[1:]) // (f[0] - 1)
	else:
		i = 1
		while f[i] == f[0]:
			f[i] -= 1
			i += 1
		ans = sum(f[1:]) // (f[0] - 1)
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(map(int, input().split()))
	q = [0] * n
	for i in x:
		q[i - 1] += 1
	maxx = max(q)
	c = 0
	for i in q:
		if i == maxx:
			c = c + 1
	if maxx == 1:
		print(0)
	else:
		a = (n - c * maxx) // (maxx - 1)
		print(a + c - 1)


def solve(n, ar):
	freq = [0] * 200000
	for i in range(n):
		freq[ar[i]] += 1
	maxi = 0
	max_freq = 0
	for i in range(len(freq)):
		if maxi < freq[i]:
			maxi = max(maxi, freq[i])
			max_freq = 1
		elif freq[i] == maxi:
			max_freq += 1
	print((n - max_freq) // (maxi - 1) - 1)
t = int(input())
for _ in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	solve(n, ar)


import sys, math
from collections import Counter, deque, defaultdict
input = sys.stdin.readline
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()
C = lambda : input().strip().split()
mod = 1000000007

def s(a):
	print(''.join(list(map(str, a))))

def solve():
	n = I()
	l = L()
	d = Counter(l)
	a = list(d.values())
	m = max(a)
	c = a.count(m)
	ans = n - m - c + 1
	print(ans // (m - 1))
for _ in range(I()):
	solve()


import sys
import math
read = sys.stdin.buffer.read
readlines = sys.stdin.buffer.readlines
t = int(input())
for case in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = [0] * (10 ** 5 + 1)
	for i in range(n):
		cnt[a[i]] += 1
	k = max(cnt)
	m = cnt.count(k)
	print((n - m) // (k - 1) - 1)


def abc(v, k, n):
	for j in range(len(k)):
		if j + k[j] + (k[j] - 1) * v <= n:
			pass
		else:
			return 0
	return 1

def bs(x, n):
	i = 0
	j = n
	ans = 0
	while i <= j:
		mid = i + (j - i) // 2
		if abc(mid, x, n):
			ans = mid
			i = mid + 1
		else:
			j = mid - 1
	return ans
t = int(input())
for _ in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		try:
			d[i] += 1
		except:
			d[i] = 1
	x = list(d.values())
	x.sort(reverse=True)
	print(bs(x, n))


for _ in range(int(input())):
	n = int(input())
	b = [0 for _ in range(n)]
	a = [int(x) for x in input().split()]
	for x in a:
		b[x - 1] += 1
	maxi = max(b)
	ctm = 0
	for x in b:
		if x == maxi:
			ctm += 1
	print((n - ctm) // (maxi - 1) - 1)


from sys import stdin, stdout
input = stdin.readline
from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = [[i, j] for (i, j) in Counter(a).items()]
	c.sort(key=lambda x: x[1], reverse=True)
	m = 0
	t = c[0][1]
	b = [[c[i][0] for i in range(len(c)) if c[i][1] == t] for _ in range(t)]
	for i in range(len(c)):
		if c[i][1] == t:
			c[i][1] = 0
		else:
			t = i
			break
	i = 0
	c = c[t:]
	j = 0
	for ci in c:
		while ci[1]:
			j = j % (len(b) - 1)
			b[j].append(ci[0])
			j += 1
			ci[1] -= 1
	B = []
	for bi in b:
		B.extend(bi)
	s = dict()
	ans = n
	for (i, j) in enumerate(B):
		if j not in s:
			s[j] = i
		else:
			ans = min(ans, i - s[j] - 1)
			s[j] = i
	print(ans)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	c = Counter(arr)
	q = c.most_common()[0][1]
	x = 0
	for i in c:
		if c[i] == q:
			x += 1
	print((n - x) // (q - 1) - 1)


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())

def ri():
	return int(f.readline().strip())

def ria():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def rs():
	return list(f.readline().strip())

def bi(x):
	return bin(x)[2:]
from collections import deque
import math
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m

def choose(n, k):
	if n < k:
		assert false
	return mult(factorial(n), modinv(mult(factorial(k), factorial(n - k)))) % NUMBER
from collections import deque, defaultdict
import heapq
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def dfs(g, timeIn, timeOut, depths, parents):
	cnt = 0
	stack = [[1, 0, 0, 0]]
	while stack:
		(v, neig_i, parent, depth) = stack[-1]
		parents[v] = parent
		depths[v] = depth
		if neig_i == 0:
			timeIn[v] = cnt
			cnt += 1
		while neig_i < len(g[v]):
			u = g[v][neig_i]
			if u == parent:
				neig_i += 1
				continue
			stack[-1][1] = neig_i + 1
			stack.append([u, 0, v, depth + 1])
			break
		if neig_i == len(g[v]):
			stack.pop()
			timeOut[v] = cnt
			cnt += 1
cnt = 0

@bootstrap
def dfs(v, adj, timeIn, timeOut, depths, parents, parent=0, depth=0):
	global cnt
	parents[v] = parent
	depths[v] = depth
	timeIn[v] = cnt
	cnt += 1
	for u in adj[v]:
		if u == parent:
			continue
		yield dfs(u, adj, timeIn, timeOut, depths, parents, v, depth + 1)
	timeOut[v] = cnt
	cnt += 1
	yield

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def lcm(a, b):
	return a * b / gcd(a, b)

def get_num_2_5(n):
	twos = 0
	fives = 0
	while n > 0 and n % 2 == 0:
		n //= 2
		twos += 1
	while n > 0 and n % 5 == 0:
		n //= 5
		fives += 1
	return (twos, fives)

def shift(a, i, num):
	for _ in range(num):
		(a[i], a[i + 1], a[i + 2]) = (a[i + 2], a[i], a[i + 1])

def equal(x, y):
	return abs(x - y) <= 1e-09

def getAngle(a, b, c):
	ang = math.degrees(math.atan2(c[1] - b[1], c[0] - b[0]) - math.atan2(a[1] - b[1], a[0] - b[0]))
	return ang + 360 if ang < 0 else ang

def getLength(a, b):
	return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
from heapq import heapify, heappush, heappop

def bfs(adj):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

def isSubsetSum(arr, n, summ):
	subarr = [[False for i in range(summ + 1)] for i in range(n + 1)]
	for i in range(n + 1):
		subarr[i][0] = True
	for i in range(1, summ + 1):
		subarr[0][i] = False
	for i in range(1, n + 1):
		for j in range(1, summ + 1):
			if j < arr[i - 1]:
				subarr[i][j] = subarr[i - 1][j]
			if j >= arr[i - 1]:
				subarr[i][j] = subarr[i - 1][j] or subarr[i - 1][j - arr[i - 1]]
	return subarr[n][summ]

def bfs(v, adj, onpath):
	s = set()
	d = defaultdict(set)
	q = deque([])
	s.add(0)
	d[0].add(0)
	q.append((0, 0))
	while len(q) > 0:
		(v, depth) = q.popleft()
		for u in adj[v]:
			if u not in s:
				s.add(u)
				d[depth + 1].add(u)
				q.append((u, depth + 1))
	return d

def solution(a, n):
	d = defaultdict(int)
	for x in a:
		d[x] += 1
	mx_ap = max(d.values())
	cnt = 0
	for x in d:
		if d[x] == mx_ap:
			cnt += 1
	n -= cnt * mx_ap
	return n // (mx_ap - 1) + (cnt - 1)

def main():
	T = 1
	T = ri()
	for i in range(T):
		n = ri()
		a = ria()
		x = solution(a, n)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


t = int(input())
from collections import Counter
from bisect import bisect
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	c = Counter(l)
	l1 = []
	for j in c:
		l1.append(c[j])
	l1.sort()
	c1 = Counter(l1)
	b = c1[l1[-1]]
	a = (n - l1[-1] - (b - 1)) // (l1[-1] - 1)
	print(a)


def main():
	T = int(input())
	for _ in range(T):
		n = int(input())
		a = list(map(int, input().split()))
		freq = {}
		for i in a:
			if i not in freq:
				freq[i] = 1
			else:
				freq[i] += 1
		M = freq[max(freq, key=lambda x: freq[x])]
		c = 0
		for k in freq:
			if freq[k] == M:
				c += 1
		n -= c - 1
		y = int((n - 1) / (M - 1))
		print(y - 1)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0] * n
	for i in range(n):
		d[a[i] - 1] += +1
	d.sort(reverse=True)
	k = 0
	for i in range(1, n):
		if d[i] == d[0]:
			k += 1
		else:
			break
	print((n - d[0] - k) // (d[0] - 1))


import sys
from collections import Counter, deque
from heapq import heappush, heappop

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7

def bisearch_max(mn, mx, func):
	ok = mn
	ng = mx
	while ok + 1 < ng:
		mid = (ok + ng) // 2
		if func(mid):
			ok = mid
		else:
			ng = mid
	return ok

def check(m):
	tmp = deque()
	que = []
	for (k, v) in C.items():
		heappush(que, (-v, k))
	while que:
		(v, k) = heappop(que)
		v = -v
		v -= 1
		tmp.append((v, k))
		if len(tmp) >= m:
			(v, k) = tmp.popleft()
			if v:
				heappush(que, (-v, k))
	for (v, k) in tmp:
		if v:
			return False
	return True
for _ in range(INT()):
	N = INT()
	A = LIST()
	C = Counter(A)
	res = bisearch_max(0, N, check) - 1
	print(res)


import sys
input = sys.stdin.readline
from collections import Counter
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	c = list(Counter(a).values())
	c.sort(reverse=True)
	k = list(Counter(c).values())
	if k[0] == 1:
		print((n - c[0]) // (c[0] - 1))
	else:
		nn = n - c[0] * k[0] + c[0]
		print((nn - c[0]) // (c[0] - 1) + (k[0] - 1))


import sys
input = sys.stdin.readline
from collections import Counter
t = int(input())
for tests in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	C = Counter(A)
	MAX = 0
	count = 0
	for c in C:
		if C[c] > MAX:
			MAX = C[c]
			count = 1
		elif C[c] == MAX:
			count += 1
	n -= count - 1
	n -= 1
	n //= MAX - 1
	print(n - 1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split()))
	li = [0] * (n + 1)
	for i in range(n):
		li[ar[i]] += 1
	ma = max(li)
	count = 0
	for i in li:
		if i == ma:
			count += 1
	rest = n - count * ma
	print(rest // (ma - 1) + count - 1)


import math
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
import threading
from collections import defaultdict
threading.stack_size(10 ** 8)
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
sys.setrecursionlimit(300000)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default='z', func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] >= k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater
for ik in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = defaultdict(int)
	for i in range(n):
		d[l[i]] += 1
	m = max(d.values())
	l = list(d.values())
	cou = l.count(m)
	ans = (n - m * cou) // (m - 1) + cou - 1
	print(ans)


import math
from collections import Counter
bags = int(input())
for t in range(bags):
	n = int(input())
	a = list(map(int, input().split()))
	a = Counter(a)
	a1 = [(a[i], i) for i in a if a[i] > 1]
	a1 = sorted(a1)[::-1]
	la = len(a1)
	mv = n + 1
	for (val, i) in a1:
		v = (n - 1) // (val - 1) - 1
		mv = min(mv, v)
		n -= 1
	print(mv)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
from collections import Counter

def counter_to_list(counter):
	return [key for key in counter.keys() for _ in range(counter[key])]

def minimum_distance_for_same_value_maximum(data, get_order=False):
	data = Counter(data)
	most = data.most_common(1)[0][1]
	most_num = tuple(data.values()).count(most)
	interval = (sum(data.values()) - most * most_num) // (most - 1)
	min_distance = most_num - 1 + interval
	if not get_order:
		return min_distance
	most_common = [key for key in data.keys() if data[key] == most]
	for key in most_common:
		del data[key]
	others = counter_to_list(data)
	result = []
	for _ in range(most):
		result.extend(most_common)
		result.extend(others[-interval:])
		del others[-interval:]
	return (min_distance, result)
DEBUG = False
for case in range(1, itg() + 1):
	itg()
	print(minimum_distance_for_same_value_maximum(mpint(), DEBUG))


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	ls = get_list()
	freq_dic = Counter(ls)
	highest_freq = freq_dic.most_common()[0][1]
	no_of_ele = 0
	for (key, val) in freq_dic.items():
		if val == highest_freq:
			no_of_ele += 1
	ans = 0
	f = no_of_ele * highest_freq
	while f + (highest_freq - 1) * ans <= n:
		ans += 1
	print(ans - 1 + no_of_ele - 1)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


production = True
import sys, math, collections, bisect, itertools, heapq, decimal, random, copy, re

def input(f=0, m=0):
	if m > 0:
		return [input(f) for i in range(m)]
	else:
		l = sys.stdin.readline()[:-1]
		if f >= 10:
			u = False
			f = int(str(f)[-1])
		else:
			u = True
		if f == 0:
			p = [l]
		elif f == 1:
			p = list(map(int, l.split()))
		elif f == 2:
			p = list(map(float, l.split()))
		elif f == 3:
			p = list(l)
		elif f == 4:
			p = list(map(int, list(l)))
		elif f == 5:
			p = l.split()
		return p if u else p[0]

def out(l, f=0, n=True):
	if f == 0:
		p = str(l)
	elif f == 1:
		p = ' '.join(map(str, l))
	elif f == 2:
		p = '\n'.join(map(str, l))
	elif f == 3:
		p = ''.join(map(str, l))
	print(p, end='\n' if n else '')

def log(*args):
	if not production:
		print('$$$', end='')
		print(*args)
enu = enumerate
ter = lambda a, b, c: b if a else c
ceil = lambda a, b: -(-a // b)

def mapl(i, f=0):
	if f == 0:
		return list(map(int, i))
	elif f == 1:
		return list(map(str, i))
	elif f == 2:
		return list(map(list, i))

def solve():
	n = input(11)
	a = input(1)
	r = [0] * (10 ** 5 + 1)
	for i in a:
		r[i] += 1
	r.sort(reverse=1)
	m = r[0]
	tm = -1
	for i in r:
		if i == m:
			tm += 1
	log(n, m, tm)
	ans = tm
	n -= m + tm * m
	log(n)
	ans += n // (m - 1)
	out(ans)
	log()
	return
for i in range(input(11)):
	solve()


import os
import heapq
import sys, threading
import math
import bisect
import operator
from collections import defaultdict
sys.setrecursionlimit(10 ** 5)
from io import BytesIO, IOBase

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def power(x, p, m):
	res = 1
	while p:
		if p & 1:
			res = res * x % m
		x = x * x % m
		p >>= 1
	return res

def inar():
	return [int(k) for k in input().split()]

def lcm(num1, num2):
	return num1 * num2 // gcd(num1, num2)

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		arr = inar()
		heap = []
		heapq.heapify(heap)
		res = []
		dic = defaultdict(int)
		for i in range(n):
			dic[arr[i]] += 1
		mx = max(dic.values())
		take = defaultdict(int)
		for (key, item) in dic.items():
			take[item] += 1
		if take[mx] == 1:
			print((n - mx) // (mx - 1))
		else:
			print((n - take[mx] * mx) // (mx - 1) + take[mx] - 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from __future__ import division, print_function
import sys
from atexit import register
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
sys.stdin = stream(sys.stdin.read())
input = lambda : sys.stdin.readline().rstrip('\r\n')
sys.stdout = stream()
register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def read_int():
	return int(input())

def read_ints():
	return list(map(int, input().split(' ')))
from collections import Counter

def solve():
	N = read_int()
	A = read_ints()
	counter = Counter(A)
	(_, c) = counter.most_common(1)[0]
	count = sum((1 for (k, v) in counter.items() if v == c))
	return (N - count) // (c - 1) - 1
T = read_int()
for _ in range(T):
	print(solve())


from collections import Counter
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(Counter(map(int, input().split())).values())
	ma = max(a)
	k = a.count(ma)
	print((n - k) // (ma - 1) - 1)


for _ in range(int(input())):
	n = int(input())
	fillings = list(map(int, input().split()))
	l = [0] * 100000
	for i in range(n):
		l[fillings[i] - 1] += 1
	c = max(l)
	f = l.count(c)
	print((n - f) // (c - 1) - 1)


import sys
input = sys.stdin.readline
from collections import defaultdict
(T,) = map(int, input().split())
for _ in range(T):
	D = defaultdict(int)
	(N,) = map(int, input().split())
	X = list(map(int, input().split()))
	for x in X:
		D[x] += 1
	l = sorted(list(D.values()))
	mx = l[-1]
	sll = 0
	R = -1
	for x in l:
		if x < mx:
			sll += x
		else:
			R += 1
	print(R + sll // (mx - 1))


test = int(input())
k = 1
while k <= test:
	k += 1
	n = int(input())
	a = list(map(int, input().split()))
	c = [0 for i in range(len(a) + 1)]
	for i in a:
		c[i] += 1
	maxi = max(c)
	count = 0
	for s in c:
		if s == maxi:
			count += 1
	rem = n - maxi * count
	div = rem // (maxi - 1)
	print(div + count - 1)


from collections import Counter

def solve(arr):
	n = len(arr)
	mp = Counter(arr)
	fmax = max(mp.values())
	m = sum((1 for f in mp.values() if f == fmax))
	h = (n - m * fmax) // (fmax - 1)
	return h + m - 1
for _ in range(int(input())):
	input()
	arr = list(map(int, input().split()))
	print(solve(arr))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections

def main():
	for j in range(int(input())):
		n = int(input())
		vals = list(map(int, input().split()))
		dict1 = collections.defaultdict(int)
		for s in range(n):
			dict1[vals[s]] += 1
		maxy = [[dict1[k], k] for k in dict1.keys()]
		maxy.sort(key=lambda x: x[0])
		ans = [[maxy[-1][1]] for s in range(maxy[-1][0])]
		maxy.pop()
		cv = 0
		while len(maxy) > 0:
			v0 = maxy.pop()
			num = v0[1]
			reps = v0[0]
			if reps < len(ans):
				while reps > 0:
					ans[cv % (len(ans) - 1)].append(num)
					cv += 1
					reps -= 1
			else:
				while reps > 0:
					ans[cv % len(ans)].append(num)
					cv += 1
					reps -= 1
		mindist = n - 1
		for s in range(len(ans) - 1):
			dist = len(ans[s]) - 1
			if dist < mindist:
				mindist = dist
		print(mindist)
main()


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	f = {}
	for i in l:
		if i in f:
			f[i] += 1
		else:
			f[i] = 1
	t = max(f.values())
	ans = 0
	p = 0
	for i in f.values():
		if i >= t - 1:
			ans += 1
		else:
			p += i
	print(ans - 1 + p // (t - 1))


from sys import stdin, stdout

def input():
	return stdin.readline().strip()
from collections import defaultdict, Counter

def ans(A):
	cA = Counter(A)
	max_freq = max(cA.values())
	ret = -1
	fodder = 0
	for c in cA:
		if cA[c] == max_freq:
			ret += 1
		else:
			fodder += cA[c]
	max_freq -= 1
	assert max_freq >= 0
	return ret + fodder // max_freq
T = int(input())
for _ in range(T):
	input()
	A = list(map(int, input().split()))
	print(ans(A))


T = int(input())
for case in range(T):
	i = int(input())
	ls = [int(x) for x in input().split()]
	d = {}
	for e in ls:
		try:
			d[e] += 1
		except:
			d[e] = 1
	l = sorted([(k, v) for (k, v) in d.items()], key=lambda x: x[1], reverse=True)
	m = l[0][1]
	c = 0
	for e in l:
		if e[1] == m:
			c += 1
		else:
			break
	intervals = m - 1
	rem = len(ls) - c * m
	junk = rem // intervals
	print(junk + c - 1)


T = int(input())
ans = []
for i in range(T):
	n = int(input())
	a = list(map(int, input().split()))
	c = [0] * (n + 1)
	max1 = 0
	c_max = 0
	for j in a:
		c[j] += 1
	for j in c:
		if j > max1:
			max1 = j
			c_max = 1
		elif j == max1:
			c_max += 1
	ans.append((n - max1 * c_max) // (max1 - 1) + c_max - 1)
for i in ans:
	print(i)


from collections import Counter

def solve():
	N = int(input())
	A = list(map(int, input().split()))
	C = sorted(Counter(A).values(), reverse=True)

	def check(m):
		for (i, c) in enumerate(C):
			if (c - 1) * (m + 1) + i >= N:
				return False
		return True
	(lb, ub) = (-1, N)
	while ub - lb > 1:
		m = (lb + ub) // 2
		if check(m):
			lb = m
		else:
			ub = m
	return lb
TC = int(input())
for _ in range(TC):
	print(solve())


import sys
import heapq
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	l = int(input())
	p = list(map(int, input().split()))
	a = [0 for n in range(max(p) + 1)]
	for num in p:
		a[num] += 1
	a.sort(reverse=True)
	c = 1
	for j in range(1, len(a) - 1):
		if a[j] == a[j - 1]:
			c += 1
		else:
			break
	seg = l - c + 1
	f = (seg - 1) // (a[0] - 1)
	print(f - 1)


for i in range(int(input())):
	temp = input()
	mylist = input().split()
	mydict = {}
	biggest = [0, 0]
	for k in mylist:
		if k in mydict:
			mydict[k] += 1
		else:
			mydict[k] = 1
		if mydict[k] > biggest[0]:
			biggest = [mydict[k], 1]
		elif mydict[k] == biggest[0]:
			biggest[1] += 1
	print(int(biggest[1] - 1 + (len(mylist) - biggest[0] * biggest[1]) / (biggest[0] - 1)))


import sys
import math, bisect
from collections import defaultdict
from itertools import groupby, accumulate
from heapq import heapify, heappop, heappush
from collections import deque, Counter, OrderedDict
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__

def neo():
	return map(int, input().split())

def Neo():
	return list(map(int, input().split()))
for _ in range(int(input())):
	N = int(input())
	A = Neo()
	Z = Counter(A)
	t = max(Z.values())
	Ans = 0
	p = 0
	for i in Z.values():
		if i >= t - 1:
			Ans += 1
		else:
			p += i
	print(Ans - 1 + p // (t - 1))


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	ans = [0] * (n + 1)
	for i in a:
		ans[i] += 1
	Max = max(ans)
	maxnum = ans.count(Max)
	ans = (n - maxnum) // (Max - 1) - 1
	print(ans)


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
import random
sys.setrecursionlimit(10 ** 6)
from queue import PriorityQueue
from collections import Counter as cc
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from itertools import permutations
from math import factorial as f

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p
import sys
t = int(input())
for _ in range(t):
	n = int(input())
	hash = defaultdict(int)
	l = list(map(int, input().split()))
	for i in l:
		hash[i] += 1
	la = []
	for i in hash:
		la.append([hash[i], i])
	la.sort(reverse=True)
	cnt = 0
	z = la[0][0]
	for (a, b) in la:
		if a == z:
			cnt += 1
	print((n - z * cnt) // (z - 1) + cnt - 1)


from __future__ import division, print_function

def main():
	for _ in range(int(input())):
		n = int(input())
		cakes = list(map(int, input().split()))
		count = {}
		max_count = 0
		for x in cakes:
			if x not in count:
				count[x] = 0
			count[x] += 1
			max_count = max(max_count, count[x])
		temp = 0
		for x in count:
			if count[x] == max_count:
				temp += 1
		n -= (temp - 1) * max_count
		answer = (n - max_count) // (max_count - 1) + (temp - 1)
		print(answer)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def readnumbers(zero=0):
	conv = ord if py2 else lambda x: x
	A = []
	numb = zero
	sign = 1
	i = 0
	s = sys.stdin.buffer.read()
	try:
		while True:
			if s[i] >= b'0'[0]:
				numb = 10 * numb + conv(s[i]) - 48
			elif s[i] == b'-'[0]:
				sign = -1
			elif s[i] != b'\r'[0]:
				A.append(sign * numb)
				numb = zero
				sign = 1
			i += 1
	except:
		pass
	if s and s[-1] >= b'0'[0]:
		A.append(sign * numb)
	return A
main()


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	d = defaultdict(int)
	a = list(map(int, input().split()))
	for x in a:
		d[x] += 1
	counts = list(d.values())
	m = max(counts)
	count = counts.count(m)
	gaps = n - count * m
	gap = gaps // (m - 1)
	print(gap + count - 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = set(a)
	b = list(b)
	c = [0] * (n + 1)
	for i in a:
		c[i] += 1
	d = [0] * len(b)
	for i in range(len(b)):
		d[i] = c[b[i]]
	d.sort()
	cnt = d.count(d[-1])
	print((n - cnt - (d[-1] - 1)) // (d[-1] - 1))


from sys import *
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	d = [0] * (n + 1)
	for i in a:
		d[i] += 1
	c = [0] * (n + 1)
	for i in d:
		c[i] += 1
	div = 1
	for i in range(n, -1, -1):
		if c[i] > 0:
			div = i - 1
			break
	val = 0
	for i in range(1, div + 1):
		val += c[i] * i
	ans = val // div
	print(ans + c[div + 1] - 1)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	dp = [0] * (n + 1)
	for i in a:
		dp[i] += 1
	m = max(dp)
	h = dp.count(m)
	print((n - h) // (m - 1) - 1)


from collections import *
t = int(input())
for _ in range(t):
	a = int(input())
	arr = list(map(int, input().split()))
	c = Counter(arr)
	d = defaultdict(int)
	maxm = 0
	for (i, j) in c.items():
		if j > maxm:
			maxm = j
		d[j] += 1
	if d[maxm] == 1:
		print((a - maxm) // (maxm - 1))
	else:
		total = a
		rep = d[maxm] - 1
		temp = (a - d[maxm] * maxm) // (maxm - 1)
		print(rep + temp)


import os, sys
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		arr = [0] * (n + 1)
		for i in a:
			arr[i] += 1
		x = max(arr)
		y = arr.count(x)
		print((n - y - x + 1) // (x - 1))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import heapq
from collections import Counter
for _ in range(int(input())):
	n = int(input())
	a = [int(o) for o in input().split()]
	d = dict(Counter(a))
	h = []
	for i in d:
		heapq.heappush(h, [-d[i], i])
	arr = []
	ma = h[0][0]
	while h and h[0][0] == ma:
		lol = heapq.heappop(h)
		arr.append(lol[1])
	ans = []
	for i in range(-ma - 1):
		ans.append(arr[:])
	la = len(ans)
	i = 0
	while h:
		lol = heapq.heappop(h)
		for j in range(-lol[0]):
			ans[i].append(lol[1])
			i += 1
			i %= la
	ans.append(arr[:])
	fa = []
	for i in ans:
		for j in i:
			fa.append(j)
	prev = dict()
	ma = float('inf')
	for i in range(len(fa)):
		if fa[i] in prev:
			ma = min(ma, i - prev[fa[i]] - 1)
		prev[fa[i]] = i
	print(ma)


import sys

def input():
	return sys.stdin.readline().rstrip()

def input_split():
	return [int(i) for i in input().split()]
testCases = int(input())
answers = []
for _ in range(testCases):
	n = int(input())
	arr = input_split()
	counts = {a: 0 for a in arr}
	for a in arr:
		counts[a] += 1
	temp = list(counts.values())
	temp.sort()
	temp.reverse()
	k = 0
	val = temp[0]
	ptr = 1
	while ptr < len(temp):
		if temp[ptr] != val:
			break
		ptr += 1
		k += 1
	n = n - k
	ans = (n - val) // (val - 1)
	answers.append(ans)
print(*answers, sep='\n')


import os
import sys
from io import BytesIO, IOBase
import threading
from collections import Counter
import heapq
from math import ceil, floor

def main():
	n = int(input())
	arr = list(map(int, input().split()))
	c = Counter(arr)
	a = list(c.values())
	a.sort(reverse=True)
	s = set(arr)
	if len(s) == n:
		print(n)
	else:
		l = 0
		r = len(s) - 1
		prev = 0
		while l <= r:
			mid = l + (r - l) // 2
			k = ceil(n / (mid + 1))
			c1 = c2 = c3 = 0
			for i in a:
				if i > k:
					c1 += 1
				if i == k:
					c2 += 1
			if c1 > 0 or c2 > (mid + 1 if n % (mid + 1) == 0 else n % (mid + 1)):
				r = mid - 1
			else:
				l = mid + 1
				prev = mid
		print(prev)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(int(input())):
	main()


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	N = int(input())
	a = list(map(int, input().split()))
	table = [0] * (N + 1)
	for x in a:
		table[x] += 1
	mx = max(table)
	c = table.count(mx)
	t = (N - c * mx) // (mx - 1) + c - 1
	if a.count(mx) == N:
		print(0)
		continue
	print(t)


from collections import Counter
for _ in range(int(input())):
	n = int(input())
	arr = [int(x) for x in input().split()]
	cnt = Counter(arr)
	mxkey = max(cnt.values())
	mxcnt = 0
	for i in cnt.values():
		if i == mxkey:
			mxcnt += 1
	rem = n - mxkey * mxcnt
	ans = mxcnt - 1 + rem // (mxkey - 1)
	print(ans)


from collections import Counter
t = int(input())
while t:
	t -= 1
	n = int(input())
	a = [int(j) for j in input().split()]
	c = Counter(a)
	l = sorted(c, key=lambda x: -c[x])
	max = c[l[0]]
	x = 0
	y = 0
	for i in l:
		if c[i] == max:
			x += 1
		else:
			y += c[i]
	print(y // (max - 1) + x - 1)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
from collections import defaultdict as dc
for _ in range(N()):
	n = N()
	nums = RLL()
	dic = dc(int)
	for i in nums:
		dic[i] += 1
	m = max(dic.values())
	tmp = 0
	for k in dic:
		if dic[k] == m:
			tmp += 1
	res = (n - (tmp - 1) - m) // (m - 1)
	print(res)


import sys
import heapq, functools, collections
import math, random
from collections import Counter, defaultdict

def solve(lst):
	console('----- solving ------')
	console(lst)
	c = Counter(lst)
	if len(c) == 1:
		return 0
	freqs = sorted(c.values())
	freqsfreqs = Counter(freqs)
	console(freqs)
	console(freqsfreqs)
	max_freq = freqs[-1]
	cnt = freqsfreqs[max_freq]
	gap = (len(lst) - cnt * max_freq) // (max_freq - 1)
	return gap + cnt - 1

def console(*args):
	return
for case_num in range(int(input())):
	_ = int(input())
	lst = list(map(int, input().split()))
	res = solve(lst)
	print(res)


from collections import Counter
T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	C = Counter(A)
	C_max = max(C.values())
	cnt = list(C.values()).count(C_max)
	N -= (cnt - 1) * C_max
	x = (N - 1) // (C_max - 1) - 1
	x += cnt - 1
	print(x)


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	n = int(input())
	(*a,) = map(int, input().split())
	cnt = [0] * (n + 1)
	for i in a:
		cnt[i] += 1
	b = mx = 0
	for i in cnt:
		if i == mx:
			b += 1
		elif i > mx:
			(mx, b) = (i, 1)
	print((n - b) // (mx - 1) - 1)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	for i in l:
		d[i] = 0
	for i in l:
		d[i] += 1
	a = 0
	mx = 0
	b = 0
	for i in d:
		mx = max(d[i], mx)
	for i in d:
		if d[i] == mx:
			a += 1
		else:
			b += d[i]
	print(b // (mx - 1) + a - 1)


import sys
input = sys.stdin.readline
from bisect import bisect_left
from bisect import bisect_right
from math import ceil, factorial

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	n = int(input())
	a = int_array()
	dick = {}
	for i in a:
		dick[i] = dick.get(i, 0) + 1
	f = sorted(list(dick.values()))
	mx = max(f) - 1
	ans = 0
	while f and f[-1] >= mx:
		ans += 1
		f.pop()
	ans += sum(f) // mx
	print(ans - 1)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	a = sorted([int(i) for i in input().split()])
	num = [0 for i in range(n)]
	act_num = 0
	num[0] = 1
	for i in range(1, n):
		if a[i] == a[i - 1]:
			num[act_num] += 1
		else:
			act_num += 1
			num[act_num] = 1
	candies = sorted(num[:act_num + 1], reverse=True)
	ans = 0
	gaps = candies[0] - 1
	free = gaps
	for i in candies[1:]:
		if i >= gaps:
			ans += 1
		elif i < free:
			free -= i
		else:
			free = gaps + free - i
			ans += 1
	print(ans)


import math
import sys
from collections import Counter
from queue import Queue
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s[:len(s) - 1]

def invr():
	return map(int, input().split())

def twosum(val, W):
	C = Counter(W)
	out = 0
	for i in range(len(W)):
		if C[W[i]] > 0:
			C[W[i]] -= 1
			if C[val - W[i]] > 0:
				out += 1
				C[val - W[i]] -= 1
	return out
T = inp()
for t in range(T):
	N = inp()
	A = inlt()
	C = Counter(A)
	maxx = 0
	for c in C:
		if C[c] > maxx:
			maxx = C[c]
	cnt = -1
	for c in C:
		if C[c] == maxx:
			cnt += 1
	print((N - maxx - cnt) // (maxx - 1))


from sys import stdin
from collections import defaultdict
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().rstrip().split(' ')))
	d = defaultdict(lambda : 0)
	mxrep = 0
	for ele in a:
		d[ele] += 1
		mxrep = max(mxrep, d[ele])
	filler = 0
	for (key, value) in d.items():
		filler += min(mxrep - 1, value)
	filler -= mxrep - 1
	slots = mxrep - 1
	ans = filler // slots
	print(ans)


from sys import stdin, exit
from bisect import bisect_left as bl, bisect_right as br
input = lambda : stdin.readline()[:-1]
intput = lambda : int(input())
sinput = lambda : input().split()
intsput = lambda : map(int, sinput())

def dprint(*args, **kwargs):
	if debugging:
		print(*args, **kwargs)
debugging = 1
t = intput()
for _ in range(t):
	n = intput()
	a = list(intsput())
	a.sort()
	counts = []
	cnt = 1
	prev = a[0]
	for i in range(1, len(a)):
		if a[i] != prev:
			counts.append(cnt)
			cnt = 0
		cnt += 1
		prev = a[i]
	counts.append(cnt)
	counts.sort(reverse=True)
	cnt = 0
	for x in counts:
		if x == counts[0]:
			cnt += 1
		else:
			break
	n -= cnt - 1
	n -= counts[0]
	print(n // (counts[0] - 1))