Eshag has an array $a$ consisting of $n$ integers.

Eshag can perform the following operation any number of times: choose some subsequence of $a$ and delete every element from it which is strictly larger than $AVG$, where $AVG$ is the average of the numbers in the chosen subsequence.

For example, if $a = [1 , 4 , 3 , 2 , 4]$ and Eshag applies the operation to the subsequence containing $a_1$, $a_2$, $a_4$ and $a_5$, then he will delete those of these $4$ elements which are larger than $\frac{a_1+a_2+a_4+a_5}{4} = \frac{11}{4}$, so after the operation, the array $a$ will become $a = [1 , 3 , 2]$.

Your task is to find the maximum number of elements Eshag can delete from the array $a$ by applying the operation described above some number (maybe, zero) times.

A sequence $b$ is a subsequence of an array $c$ if $b$ can be obtained from $c$ by deletion of several (possibly, zero or all) elements.


-----Input-----

The first line contains an integer $t$ $(1\le t\le 100)$ — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer $n$ $(1\le n\le 100)$ — the length of the array $a$.

The second line of each test case contains $n$ integers $a_1, a_2, \ldots, a_n$ $(1\le a_i \le 100)$ — the elements of the array $a$.


-----Output-----

For each test case print a single integer — the maximum number of elements Eshag can delete from the array $a$.


-----Examples-----

Input
3
6
1 1 1 2 2 3
6
9 9 9 9 9 9
6
6 4 1 1 4 1
Output
3
0
3


-----Note-----

Consider the first test case.

Initially $a = [1, 1, 1, 2, 2, 3]$.

In the first operation, Eshag can choose the subsequence containing $a_1$, $a_5$ and $a_6$, their average is equal to $\frac{a_1 + a_5 + a_6}{3} = \frac{6}{3} = 2$. So $a_6$ will be deleted.

After this $a = [1, 1, 1, 2, 2]$.

In the second operation, Eshag can choose the subsequence containing the whole array $a$, the average of all its elements is equal to $\frac{7}{5}$. So $a_4$ and $a_5$ will be deleted.

After this $a = [1, 1, 1]$.

In the second test case, Eshag can't delete any element.

Difficulty: EASY

Solutions:
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	print(n - a.count(m))


for test in range(int(input())):
	n = int(input())
	l = [int(x) for x in input().split()]
	c = l.count(min(l))
	print(n - c)


def modinv(n, p):
	return pow(n, p - 2, p)

def main():
	for case in range(int(input())):
		n = int(input())
		arr = [int(x) for x in input().split()]
		x = min(arr)
		print(n - arr.count(x))
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()


import sys
input = sys.stdin.readline
t = int(input())
while t > 0:
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ans = 0
	temp = 0
	for i in range(n):
		temp += arr[i]
		cnt = i + 1
		if arr[i] > temp // cnt:
			ans += 1
			temp -= arr[i]
	print(ans)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	x = min(arr)
	ans = 0
	for i in arr:
		if i == x:
			ans += 1
	print(n - ans)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	min1 = min(arr)
	c = 0
	for i in arr:
		if i != min1:
			c += 1
	print(c)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = 0
	while len(l) > 0:
		if l[-1] > l[0]:
			l.pop()
			c += 1
		else:
			break
	print(c)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	min_ele = min(l)
	min_count = l.count(min_ele)
	ans = n - min_count
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	c = 0
	for j in range(n):
		if a[j] != mn:
			c += 1
	print(c)


n = int(input())
for i in range(n):
	b = int(input())
	arr = [int(c) for c in input().split()]
	arr = sorted(arr)
	x = [a for a in arr if a != arr[0]]
	print(len(x))


t = int(input())
for i in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	print(n - a.count(min(a)))


import sys, math, bisect
inf = float('inf')
mod = 998244353

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

def gcd(a, b):
	return int(math.gcd(a, b))

def tobinary(n):
	return bin(n)[2:]

def binarySearch(a, x):
	i = bisect.bisect_left(a, x)
	if i != len(a) and a[i] == x:
		return i
	else:
		return -1

def lowerBound(a, x):
	i = bisect.bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def upperBound(a, x):
	i = bisect.bisect_right(a, x)
	if i != len(a) + 1 and a[i - 1] == x:
		return i - 1
	else:
		return -1

def primesInRange(n):
	ans = []
	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
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans

def primeFactors(n):
	factors = []
	while n % 2 == 0:
		factors.append(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			factors.append(i)
			n = n // i
	if n > 2:
		factors.append(n)
	return factors
from collections import deque, defaultdict, Counter
import heapq
for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	cnt = 0
	for i in arr:
		if i == arr[0]:
			cnt += 1
	print(n - cnt)


t = int(input())
for i in range(t):
	n = int(input())
	l = [int(num) for num in input().split()]
	l.sort()
	count = 0
	for j in range(0, len(l) - 1):
		if l[j] != l[j + 1] or l[j + 1] != l[0]:
			count += 1
	print(count)


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	m = min(arr)
	c = arr.count(m)
	print(n - c)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = [int(i) for i in input().split(' ')]
	print(n - arr.count(min(arr)))


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	x = input().split()
	a = [int(i) for i in x]
	m = min(a)
	count = 0
	for i in a:
		if i > m:
			count += 1
	print(count)


trails = int(input())
answer_list = []
for x in range(trails):
	n = int(input())
	numbers = input().split(' ')
	mini = 100000
	for s in numbers:
		use = int(s)
		if use < mini:
			mini = use
	coun = numbers.count(str(mini))
	answer_list.append(n - coun)
for g in answer_list:
	print(g)


def A(N, nums):
	output = N
	min_num = min(nums)
	for num in nums:
		if num == min_num:
			output -= 1
	return output
t = int(input())
for i in range(t):
	N = int(input())
	nums = list(map(int, input().split()))
	print(A(N, nums))


from math import *
t = int(input())
while t > 0:
	n = int(input())
	lst = [int(i) for i in input().split()][:n]
	p = set(lst)
	if len(p) > 1:
		lst.sort()
		p = 0
		for i in range(len(lst)):
			if lst[i] != lst[i + 1]:
				p = i + 1
				break
		lst2 = lst[p:]
		print(len(lst2))
	else:
		print('0')
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = len(a)
	m = min(a)
	x = a.count(m)
	print(k - x)


def main():
	for _ in range(int(input())):
		n = int(input())
		a = list(map(int, input().split()))
		print(n - a.count(min(a)))
main()


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	d = {}
	m = min(l)
	for i in l:
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	print(n - d[m])


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	count = 0
	minim = 101
	for num in a:
		if num < minim:
			minim = num
			count = 1
		elif num == minim:
			count += 1
	result = len(a) - count
	print(result)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	count = 0
	a.sort()
	i = n - 1
	j = 0
	while j < i:
		total = a[j] + a[i]
		avg = total / 2
		if a[j] > avg:
			count += 1
			j += 1
		elif a[i] > avg:
			count += 1
			i -= 1
		else:
			i -= 1
			j += 1
	print(count)


t = int(input())
for _ in range(t):
	n = int(input())
	lst = list(map(int, input().split()))
	mn = 101
	cnt = 0
	for item in lst:
		if item < mn:
			mn = item
			cnt = 1
		elif item == mn:
			cnt += 1
	print(n - cnt)


for _ in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	print(n - l.count(l[0]))


def fun(arr, n):
	m = min(arr)
	x = 0
	for num in arr:
		if num == m:
			x += 1
	return len(arr) - x
for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	ans = fun(arr, n)
	print(ans)


t = int(input())
ans = []
for x in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	count = 1
	for y in range(n - 1):
		if a[y] != a[y + 1]:
			break
		else:
			count = count + 1
	ans.append(n - count)
for a in ans:
	print(a)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	minA = min(a)
	count = 0
	for i in a:
		if i != minA:
			count += 1
	print(count)


t = int(input())
while t > 0:
	n = int(input())
	l = list(map(int, input().split()))
	s = list(set(l))
	if len(s) == 1:
		print('0')
	else:
		print(len(l) - l.count(min(l)))
	t = t - 1


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	min_ = min(a)
	c = a.count(min_)
	ans = n - c
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split(' ')))
	m = min(a)
	c = 0
	for x in a:
		if x > m:
			c += 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	mn = min(a)
	cnt = a.count(mn)
	print(n - cnt)


import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
import bisect, string, math, time, functools, random, fractions
from bisect import *
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

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

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

def LI_():
	return [int(i) - 1 for i in input().split()]

def AI():
	return map(int, open(0).read().split())

def S_():
	return input()

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

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

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10
	n = random.randint(1, N)
	a = RLI(n, 0, n - 1)
	return (n, a)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print(inp)
			print('naive', a1)
			print('solve', a2)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
alp = [chr(ord('a') + i) for i in range(26)]

def gcj(c, x):
	print('Case #{0}:'.format(c + 1), x)
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	ans = 0
	n = I()
	a = LI()
	m = min(a)
	ans = n - a.count(m)
	print(ans)


for _ in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	m = min(A)
	count = 0
	for elem in A:
		if elem > m:
			count += 1
	print(count)


from collections import Counter
test = int(input())
for t in range(test):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	d = Counter(l)
	avg = l[0] * d[l[0]] / d[l[0]]
	count = 0
	for (key, value) in d.items():
		if key > avg:
			count += d[key]
	print(count)


t = int(input())
for _ in range(t):
	a = int(input())
	nums = list(map(int, input().split()))
	d = {}
	m = float('inf')
	for i in nums:
		m = min(i, m)
		if i in d:
			d[i] += 1
		else:
			d[i] = 1
	print(len(nums) - d[m])


t = int(input())
while t > 0:
	t -= 1
	n = input()
	arr = list(map(int, input().split(' ')))
	m = arr[0]
	for i in arr:
		if i < m:
			m = i
	cnt = 0
	for i in arr:
		if i != m:
			cnt += 1
	print(cnt)


Test = int(input())
for _ in range(Test):
	N = int(input())
	Dta = list(map(int, input().split()))
	if Dta.count(Dta[0]) == N:
		print(0)
	else:
		print(N - Dta.count(min(Dta)))


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	print(n - arr.count(arr[0]))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(s) for s in input().split()]
	mn = min(a)
	ans = 0
	for i in range(n):
		if a[i] != mn:
			ans += 1
	print(ans)


for _ in range(0, int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort(reverse=True)
	a = min(arr)
	b = arr.count(a)
	print(n - b)


t = int(input())
for i in range(t):
	n = int(input())
	w = [int(k) for k in input().split()]
	if w.count(min(w)) != n:
		print(n - w.count(min(w)))
	else:
		print(0)


mi = lambda : map(int, input().split())

def main():
	for _ in range(int(input())):
		n = int(input())
		arr = list(mi())
		print(len(arr) - arr.count(min(arr)))
main()


for tt in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	x = l.count(l[0])
	print(n - x)


for i in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	m = min(arr)
	OTBET = 0
	for e in arr:
		if e != m:
			OTBET += 1
	print(OTBET)


out = []
for i in range(int(input())):
	lst = int(input())
	st = sorted(list(map(int, input().split())))
	stf = len(st)
	while True:
		if (st[0] + st[-1]) / 2 < st[-1]:
			st = st[:-1]
		else:
			out.append(stf - len(st))
			break
for el in out:
	print(el)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	d = 0
	l1 = list(set(l))
	while len(l1) > 1:
		s = sum(l1) // len(l1)
		for j in l:
			if s < j:
				l.remove(j)
				d += 1
		l1 = list(set(l))
	print(d)


def nihar(a, prev):
	if len(a) <= 1:
		return prev
	n = len(a)
	avg = sum(a) / n
	j = n
	for i in range(n):
		if a[i] > avg:
			j = i
			break
	su = n - j
	if su == 0:
		return prev
	else:
		return nihar(a[:j], prev + su)
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	print(nihar(a, 0))


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(n - a.count(min(a)))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	mini = min(l)
	count = l.count(mini)
	print(n - count)


tests = int(input())
for test in range(tests):
	n = int(input())
	a = [int(x) for x in input().split()]
	print(n - a.count(min(a)))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	if l.count(l[0]) == n:
		print(0)
	else:
		print(n - l.count(l[0]))


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print('0')
	else:
		a.sort()
		b = a[0]
		while a[0] == b:
			a.remove(a[0])
		print(len(a))


def fun(n, ls):
	st = sorted(ls)
	first = st[0]
	ans = 0
	count = 0
	for i in st:
		if first == i:
			count += 1
		else:
			break
	print(n - count)
T = int(input())
for i in range(T):
	n = int(input())
	ls = list(map(int, input().split()))
	fun(n, ls)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	while sum(l) // len(l) < max(l):
		m = max(l)
		l = list(filter(m.__ne__, l))
		if len(l) == 0:
			break
	print(n - len(l))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = l.count(min(l))
	print(n - c)


t = int(input())
natija = []
for i in range(t):
	n = int(input())
	satr = input()
	ruyhat = satr.split(' ')
	for i in range(n):
		ruyhat[i] = int(ruyhat[i])
	Min = min(ruyhat)
	natija.append(n - ruyhat.count(Min))
for i in range(t):
	print(natija[i])


for f in range(int(input())):
	n = input()
	mas = input().split()
	mas = [int(i) for i in mas]
	count = 0
	for i in mas:
		if i != min(mas):
			count += 1
	print(count)


while True:
	try:
		t = eval(input())
		for i in range(t):
			n = eval(input())
			list0 = list(map(int, input().split()))
			list0.sort(reverse=True)
			cnt = 0
			for j in range(n):
				if list0[j] != list0[n - 1]:
					cnt += 1
				else:
					break
			print(cnt)
	except:
		break


T = int(input())
for _ in range(T):
	N = int(input())
	A = list(map(int, input().split()))
	b = A.count(min(A))
	print(N - b)


x = lambda : map(int, input().split())
(t,) = x()
for _ in [1] * t:
	(n,) = x()
	c = 0
	m = 20000000000.0
	for i in x():
		if i <= m:
			if i == m:
				c += 1
			else:
				c = 1
				m = i
	print(n - c)


sem = 0
sum = 0
import math
a = int(input())
for i in range(0, a):
	b = int(input())
	c = list(map(int, input().split()))
	print(len(c) - c.count(min(c)))


for _ in range(int(input())):
	(l, a) = (int(input()), list(map(int, input().split())))
	m = min(a)
	print(l - a.count(m))


t = int(input())
while t:
	n = int(input())
	arr = list(map(int, input().split()))
	print(n - arr.count(min(arr)))
	t -= 1


for _ in range(int(input())):
	N = int(input())
	L = list(map(int, input().split()))
	M = min(L)
	ctr = L.count(M)
	print(N - ctr)


for tests in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	m = min(a)
	nn = len([i for i in a if i == m])
	print(n - nn)


def sol(x, y):
	y = sorted(y)
	m = y[0]
	c = 0
	for i in y:
		if i > m:
			c += 1
	return c
for i in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	print(sol(x, y))


for _ in range(int(input())):
	n = int(input())
	A = list(map(int, input().split()))
	print(n - A.count(min(A)))


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from itertools import permutations
from bisect import bisect_left as bl, bisect_right as br
from functools import lru_cache
from typing import Counter
sys.setrecursionlimit(100000000)
int_r = lambda : int(sys.stdin.readline())
str_r = lambda : sys.stdin.readline().strip()
intList_r = lambda : list(map(int, sys.stdin.readline().strip().split()))
strList_r = lambda : list(sys.stdin.readline().strip())
jn = lambda x, l: x.join(map(str, l))
mul = lambda : map(int, sys.stdin.readline().strip().split())
mulf = lambda : map(float, sys.stdin.readline().strip().split())
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
outStr = lambda x: stdout.write(str(x))
mod = 1000000007

def main():
	testcases = int_r()
	for t_c in range(testcases):
		n = int_r()
		arr = intList_r()
		ctr = dict(Counter(arr))
		outStr('{}\n'.format(n - ctr[min(arr)]))
main()


import os, sys
from io import BytesIO, IOBase
from collections import Counter
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 sieve(n):
	p = [1 for i in range(n + 1)]
	z = 2
	while z * z <= n:
		if p[z] == 1:
			for i in range(z * z, n + 1, z):
				p[i] = 0
		z += 1
	primes = [2]
	for i in range(3, n + 1, 2):
		if p[i]:
			primes.append(i)
	return primes

def ordinarynunm(x):
	ans = 0
	k = 0
	for i in range(9):
		k = k + 10 ** i
		for t in range(1, 10):
			if t * k <= x:
				ans += 1
	return ans

def findodddivisor(x):
	while x >= 2:
		x = x / 2
	if x == 1:
		return 'NO'
	else:
		return 'YES'

def bins(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 leftGreater

def findavg(y):
	s = 0
	for t in y:
		s += t
	k = s / len(y)
	return k
for i in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	count = -1
	ans = 0
	while count != 0:
		p = 0
		f = findavg(y)
		for t in y:
			if t > f:
				y.remove(t)
				p += 1
		ans += p
		if p == 0:
			count = 0
			break
	print(ans)


for test in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	print(len(a) - a.count(min(a)))


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	se = set(l)
	new = min(l)
	c = 0
	avg = sum(l) / len(l)
	for i in l:
		if i > new:
			c += 1
	print(c)


import sys

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

def slv():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	for i in range(n):
		if sum(a) < len(a) * a[-1]:
			a.pop()
		else:
			break
	print(n - len(a))
	return 0

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


num = int(input())
for n in range(num):
	ln = int(input())
	arr = [int(i) for i in input().split()]
	mn = arr[0]
	cnt = 0
	for m in arr:
		if mn == m:
			cnt += 1
		elif mn > m:
			mn = m
			cnt = 1
	print(len(arr) - cnt)


test = int(input())
for x in range(test):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	c = 0
	for x in range(1, len(l)):
		if l[x] > l[0]:
			c += 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	if n == 1:
		print(0)
	else:
		l.sort()
		avg = (l[0] + l[1]) / 2
		print(len([i for i in l if i > avg]))


import sys
from bisect import bisect_right as rb
from collections import deque
from queue import PriorityQueue
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
for _ in range(ii()):
	n = ii()
	a = il()
	t = 0
	x = min(a)
	for i in a:
		if i == x:
			t += 1
	print(n - t)


t = int(input())
while t:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	ans = len(a) - a.count(min(a))
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	ar = list(map(int, input().split()))
	c = 0
	m = min(ar)
	for j in range(len(ar)):
		if ar[j] == m:
			c += 1
	print(n - c)


ans = []
for _ in range(int(input())):
	n = int(input())
	a = sorted(map(int, input().split()))
	for i in range(n):
		if a[i] != a[0]:
			ans.append(n - i)
			break
	else:
		ans.append(0)
print('\n'.join(map(str, ans)))


from itertools import combinations, permutations, combinations_with_replacement, product
import itertools
from timeit import timeit
import timeit
import time
from time import time
from random import *
import random
import collections
import bisect
import os
import math
from collections import defaultdict, OrderedDict, Counter
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from queue import Queue, PriorityQueue
from heapq import *
from statistics import *
from math import sqrt, log10, log2, log, gcd, ceil, floor
import fractions
import copy
from copy import deepcopy
import sys
import io
sys.setrecursionlimit(10000)
mod = int(pow(10, 9)) + 7

def ncr(n, r, p=mod):
	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

def normalncr(n, r):
	r = min(r, n - r)
	count = 1
	for i in range(n - r, n + 1):
		count *= i
	for i in range(1, r + 1):
		count //= i
	return count
inf = float('inf')
adj = defaultdict(set)
visited = defaultdict(int)

def addedge(a, b):
	adj[a].add(b)
	adj[b].add(a)

def bfs(v):
	q = Queue()
	q.put(v)
	visited[v] = 1
	while q.qsize() > 0:
		s = q.get_nowait()
		print(s)
		for i in adj[s]:
			if visited[i] == 0:
				q.put(i)
				visited[i] = 1

def dfs(v, visited):
	if visited[v] == 1:
		return
	visited[v] = 1
	print(v)
	for i in adj[v]:
		dfs(i, visited)

def reverse_bisect_right(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x > a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

def reverse_bisect_left(a, x, lo=0, hi=None):
	if lo < 0:
		raise ValueError('lo must be non-negative')
	if hi is None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if x >= a[mid]:
			hi = mid
		else:
			lo = mid + 1
	return lo

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

def make_list(m):
	m += list(map(int, input().split()))

def get_str_list_in_int():
	return [int(i) for i in list(input())]

def get_str_list():
	return list(input())

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

def input_int():
	return int(input())

def matrix(a, b):
	return [[0 for i in range(b)] for j in range(a)]

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

def find_gcd(l):
	a = l[0]
	for i in range(len(l)):
		a = gcd(a, l[i])
	return a

def is_prime(n):
	sqrta = int(sqrt(n))
	for i in range(2, sqrta + 1):
		if n % i == 0:
			return 0
	return 1

def prime_factors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n //= 2
	sqrta = int(sqrt(n))
	for i in range(3, sqrta + 1, 2):
		while n % i == 0:
			n //= i
			l.append(i)
	if n > 2:
		l.append(n)
	return l

def p(a):
	if type(a) == str:
		print(a + '\n')
	else:
		print(str(a) + '\n')

def ps(a):
	if type(a) == str:
		print(a)
	else:
		print(str(a))

def kth_no_not_div_by_n(n, k):
	return k + (k - 1) // (n - 1)

def forward_array(l):
	n = len(l)
	stack = []
	forward = [0] * n
	for i in range(len(l) - 1, -1, -1):
		while len(stack) and l[stack[-1]] < l[i]:
			stack.pop()
		if len(stack) == 0:
			forward[i] = len(l)
		else:
			forward[i] = stack[-1]
		stack.append(i)
	return forward

def forward_array_notequal(l):
	n = len(l)
	stack = []
	forward = [n] * n
	for i in range(len(l) - 1, -1, -1):
		while len(stack) and l[stack[-1]] <= l[i]:
			stack.pop()
		if len(stack) == 0:
			forward[i] = len(l)
		else:
			forward[i] = stack[-1]
		stack.append(i)
	return forward

def backward_array(l):
	n = len(l)
	stack = []
	backward = [0] * n
	for i in range(len(l)):
		while len(stack) and l[stack[-1]] < l[i]:
			stack.pop()
		if len(stack) == 0:
			backward[i] = -1
		else:
			backward[i] = stack[-1]
		stack.append(i)
	return backward

def char(a):
	return chr(a + 97)

def get_length(a):
	return 1 + int(log10(a))

def issq(n):
	sqrta = int(n ** 0.5)
	return sqrta ** 2 == n

def ceil(a, b):
	return int((a + b - 1) / b)

def equal_sum_partition(arr, n):
	sum = 0
	for i in range(n):
		sum += arr[i]
	if sum % 2 != 0:
		return False
	part = [[True for i in range(n + 1)] for j in range(sum // 2 + 1)]
	for i in range(0, n + 1):
		part[0][i] = True
	for i in range(1, sum // 2 + 1):
		part[i][0] = False
	for i in range(1, sum // 2 + 1):
		for j in range(1, n + 1):
			part[i][j] = part[i][j - 1]
			if i >= arr[j - 1]:
				part[i][j] = part[i][j] or part[i - arr[j - 1]][j - 1]
	return part[sum // 2][n]

def bin_sum_array(arr, n):
	for i in range(n):
		if arr[i] % 2 == 1:
			return i + 1
	binarray = [list(reversed(bin(i)[2:])) for i in arr]
	new_array = [0 for i in range(32)]
	for i in binarray:
		for j in range(len(i)):
			if i[j] == '1':
				new_array[j] += 1
	return new_array

def ispalindrome(s):
	return s == s[::-1]

def get_prefix(l):
	if l == []:
		return []
	prefix = [l[0]]
	for i in range(1, len(l)):
		prefix.append(prefix[-1] + l[i])
	return prefix

def get_suffix(l):
	if l == []:
		return []
	suffix = [l[-1]] * len(l)
	for i in range(len(l) - 2, -1, -1):
		suffix[i] = suffix[i + 1] + l[i]
	return suffix
nc = 'NO'
yc = 'YES'
ns = 'No'
ys = 'Yes'

def yesno(a):
	print(yc if a else nc)

def reduce(dict, a):
	dict[a] -= 1
	if dict[a] == 0:
		dict.pop(a)
import sys
import io
from sys import stdin, stdout
input = sys.stdin.readline
t = 1
import time
time.sleep(0.1)
t = int(input())
for i in range(t):
	n = int(input())
	l = get_list()
	mina = min(l)
	print(n - l.count(min(l)))


T = int(input())
for j in range(T):
	n = int(input())
	a = [int(x) for x in input().split()]
	x = min(a)
	c = 0
	for i in a:
		if i != x:
			c += 1
	print(c)


import math, re, bisect, operator
from collections import Counter, deque
ReadStr = lambda : input()
ReadIntList = lambda : list(map(int, input().split()))
ReadStrList = lambda : list(map(str, input().split()))
ReadInt = lambda : int(input())
ReadMultipleValues = lambda : map(int, input().split())
ReadMultipleValuesStr = lambda : map(str, input().split())
for _ in range(ReadInt()):
	n = ReadInt()
	arr = ReadIntList()
	print(n - arr.count(min(arr)))


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = a[a.count(a[0]):]
	print(len(b))


tests = int(input())
for _ in range(tests):
	m = int(input())
	n = list(map(int, input().split()))
	print(m - n.count(min(n)))


t = int(input())
for i in range(0, t):
	n = int(input())
	lst = list(map(int, input().strip().split()))[:n]
	lst.sort()
	cnt = 0
	for j in lst:
		if j != lst[0]:
			break
		cnt += 1
	print(len(lst) - cnt)


t = int(input())
for _ in range(t):
	_ = input()
	values = list(map(int, input().split(' ')))
	min_value = min(values)
	print(len(values) - values.count(min_value))


import math
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	MIN = arr.count(arr[0])
	if MIN == n:
		print(0)
	else:
		print(n - MIN)


def Average(lst):
	return sum(lst) // len(lst)
l = []
c = 0
t = int(input())
while t > 0:
	p = int(input())
	x = map(int, input().split())
	for i in x:
		l.append(i)
	x = 0
	a = min(l)
	for i in l:
		if i == a:
			x += 1
	print(len(l) - x)
	l.clear()
	t -= 1


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

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 = sorted(li())
	mi = min(l)
	print(n - l.count(mi))


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	print(n - a.count(min(a)))


t = int(input())
for i in range(t):
	n = int(input())
	data = list(map(int, input().split(' ')))
	count = 0
	AVG = sum(data) / len(data)
	while AVG < max(data):
		databuf = []
		for el in data:
			if el < AVG:
				databuf.append(el)
		count = count + (len(data) - len(databuf))
		data = databuf
		AVG = sum(data) / len(data)
	print(count)


t = int(input())
while t:
	t -= 1
	tr = int(input())
	d = [0] * 101
	a = list(map(int, input().split()))
	for i in a:
		d[i] += 1
	i = 0
	while d[i] == 0:
		i += 1
	print(tr - d[i])


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	c = a.count(a[0])
	print(n - c)
t = int(input())
for i in range(t):
	solve()


for _ in range(int(input())):
	x = int(input())
	y = list(map(int, input().split()))
	l = min(y)
	c = 0
	for i in y:
		if i > l:
			c += 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	c = min(a)
	ans = 0
	for i in range(len(a)):
		if a[i] != c:
			ans += 1
	print(ans)


t = int(input())
for tests in range(0, t):
	n = int(input())
	s_arr = input().split(' ')
	arr = []
	for i in s_arr:
		arr.append(int(i))
	print(len(arr) - arr.count(min(arr)))


t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(i) for i in input().split()]
	print(len(a) - a.count(min(a)))


import math
t = int(input())
for i in range(t):
	n = int(input())
	arr = [int(i) for i in input().split()]
	mi = min(arr)
	lst = [i for i in arr if i > mi]
	print(len(lst))


n = int(input())
for i in range(n):
	a = int(input())
	z = [int(z) for z in input().split()]
	if len(set(z)) == 1:
		print(0)
	else:
		x = z.count(min(z))
		print(len(z) - x)


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	mi = min(arr)
	cnt = 0
	for i in arr:
		if i > mi:
			cnt += 1
	print(cnt)


a = int(input())
while a:
	a = a - 1
	n = int(input())
	x = list(map(int, input().split()))
	p = list(set(x))
	p.sort()
	print(n - x.count(p[0]))


t = int(input())
for task in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	res = 0
	m = min(a)
	for i in a:
		if i != m:
			res += 1
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	numbers = list(map(int, input().split()))
	numbers = sorted(numbers)
	count = numbers.count(numbers[0])
	ans = len(numbers) - count
	print(ans)


import math, copy
from collections import defaultdict, Counter

def fact(n):
	return 1 if n == 1 or n == 0 else n * fact(n - 1)

def prime(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 inp():
	l = list(map(int, input().split()))
	return l

def main():
	for _ in range(int(input())):
		n = int(input())
		c = 0
		l = inp()
		l.sort()
		s = sum(l) / len(l)
		while l[-1] > s:
			while l[-1] > s:
				l.pop()
				c += 1
			s = sum(l) / len(l)
		print(c)
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')
main()

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)

def random():
	rating = 100
	rating = rating * 100
	rating = rating * 100
	print(rating)


from itertools import combinations, product

def cnt(arr, n, x):
	c = 0
	for i in range(n):
		if arr[i] == x:
			c += 1
	return c
t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	x = min(arr)
	print(n - cnt(arr, n, x))


from sys import *
from collections import defaultdict as dd
from math import *
from bisect import *

def sinp():
	return input()

def inp():
	return int(sinp())

def minp():
	return map(int, sinp().split())

def linp():
	return list(minp())

def strl():
	return list(sinp())

def pr(x):
	print(x)
mod = int(1000000000.0 + 7)
for _ in range(inp()):
	n = inp()
	a = linp()
	m = a.count(min(a))
	print(n - m)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	count = 0
	if len(a) == 1:
		print(0)
		continue
	a.sort()
	i = a[0]
	j = a[1]
	avg = (i + j) / 2
	for i in a:
		if i > avg:
			count += 1
	print(count)


a = int(input())
while a > 0:
	a -= 1
	b = int(input())
	arr = list(map(int, input().split()))
	mn = min(arr)
	print(b - arr.count(mn))


for s in [*open(0)][2::2]:
	s = list(sorted(map(int, s.split())))
	(a, cnt) = (s[0], 0)
	for i in s:
		if i > a:
			cnt += 1
	print(cnt)


t = int(input())
for i in range(t):
	n = int(input())
	v = input()
	a = [int(j) for j in v.split()]
	s = min(a)
	print(n - a.count(s))


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k = min(a)
	c = 0
	for i in range(n):
		if a[i] == k:
			c += 1
	print(n - c)


n = int(input())
g = [0 for i in range(n)]
b = [0 for i in range(n)]
for i in range(n):
	t = int(input())
	a = list(map(int, input().split()))
	s = min(a)
	a.sort()
	b[i] = len(a)
	for j in range(len(a)):
		a[j] = int(a[j])
		if a[j] == s:
			g[i] += 1
		else:
			break
for i in range(n):
	print(abs(int(b[i]) - int(g[i])))


for _ in range(int(input())):
	n = int(input())
	arr = [int(i) for i in input().split()]
	arr.sort()
	count = 1
	for i in range(n - 1):
		if arr[i] == arr[i + 1]:
			count += 1
		else:
			break
	print(len(arr) - count)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	b = set(a)
	c = []
	for i in b:
		c.append(a.count(i))
	print(n - c[0])


def main():
	num_cases = int(input())
	for case_num in range(1, num_cases + 1):
		solve(case_num)

def solve(case_num):
	n = int(input())
	A = [int(x) for x in input().split()]
	print(n - A.count(min(A)))
main()


from collections import Counter
t = int(input())
for i in range(t):
	num = int(input())
	ls = list(map(int, input().split()))
	m = min(ls)
	t = Counter(ls)
	if t[m] == num:
		print(0)
	else:
		print(num - t[m])


def big_string(nums):
	c = nums.count(min(nums))
	return len(nums) - c
for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	result = big_string(nums)
	print(result)


t = int(input())
for xx in range(t):
	n = int(input())
	s = sorted(list(map(int, input().split())))
	if s[0] == s[-1]:
		print(0)
	else:
		print(len(s) - s.count(min(s)))


import sys
import math
import collections
inp = lambda : int(input())
strng = lambda : input().strip()
strl = lambda : list(input().strip())
mulf = lambda : map(float, input().strip().split())
seq = lambda : list(map(int, input().strip().split()))
mod = 10 ** 9 + 7
input = sys.stdin.readline
t = inp()
for t1 in range(t):
	n = inp()
	l = seq()
	z = min(l)
	c = 0
	for i in l:
		if i > z:
			c += 1
	print(c, flush=True)


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	a = list(map(int, input().split()))
	x = min(a)
	print(len(a) - a.count(x))
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	p = int(input())
	l = list(map(int, input().split()))
	s = 0
	for i in l:
		if i > min(l):
			s += 1
	print(s)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a1 = []
	while sum(a) / len(a) < max(a):
		s = sum(a) / len(a)
		a1 = a.copy()
		for j in range(len(a)):
			if a[j] > s:
				a1.remove(a[j])
		a = a1
	print(n - len(a))


t = int(input())
while t:
	t -= 1
	n = int(input())
	l = sorted(list(map(int, input().split())))
	print(n - l.count(l[0]))


import math
t = int(input())
for x in range(t):
	n = int(input())
	arr = [int(x) for x in input().split()]
	m = {}
	for x in arr:
		if x not in m:
			m[x] = 1
		else:
			m[x] += 1
	cnt = 0
	k = sorted(m)
	k = k[::-1]
	l = len(k)
	for i in range(l - 1):
		cnt += m[k[i]]
	print(cnt)


from sys import stdin
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	a = list(map(int, stdin.readline().split()))
	print(n - a.count(min(a)))


for s in [*open(0)][2::2]:
	a = (*map(int, s.split()),)
	print(len(a) - a.count(min(a)))


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
while t != 0:
	t -= 1
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	c = 0
	for x in a:
		if x != m:
			c += 1
	print(c)


n = int(input())
while n > 0:
	p = int(input())
	m = list(map(int, input().split(' ')))
	n -= 1
	l = len(m)
	print(len(m) - m.count(min(m)))


def solve():
	n = int(input())
	arr = list(map(int, input().split()))
	m = min(arr)
	k = arr.count(m)
	print(n - k)
t = int(input())
for _ in range(t):
	solve()


for _ in range(int(input())):
	m = int(input())
	arr = list(map(int, input().strip().split()))
	while True:
		n = len(arr)
		count = 0
		a = sum(arr) // n
		i = 0
		while i < n:
			if arr[i] > a:
				count += 1
				n -= 1
				arr.pop(i)
			else:
				i += 1
		if count == 0:
			break
	print(m - n)


t = int(input())
for i in range(t):
	n = int(input())
	s = input().split(' ')
	s = [int(x) for x in s]
	s.sort()
	m = min(s)
	contador = 0
	for y in s:
		if y == m:
			contador += 1
		else:
			break
	print(n - contador)


import sys
from sys import stdout
input = lambda : sys.stdin.readline().rstrip('\r\n')
P = lambda : list(map(int, input().split()))
from math import factorial as f, log2
from collections import deque, Counter as C
from heapq import heapify, heappop, heappush, heappushpop, heapreplace, merge
from pprint import pprint
import time
mod = 10 ** 9 + 7
a = ord('a')

def fast_exp(x, exp):
	ans = 1
	base = x
	while exp:
		if exp & 1:
			ans *= base
		base *= base
		base %= mod
		ans %= mod
		exp >>= 1
	return ans

def solve():
	n = int(input())
	l = P()
	print(n - l.count(min(l)))
tc = int(input())
for t in range(1, tc + 1):
	solve()


def main():
	import sys
	read = sys.stdin.read
	readline = sys.stdin.readline
	INF = float('INF')
	MOD = 10 ** 9 + 7
	sys.setrecursionlimit(10 ** 5)
	T = int(readline())
	for _ in range(T):
		N = int(readline())
		A = list(map(int, readline().split()))
		A.sort()
		m = min(A)
		c = A.count(m)
		print(len(A) - c)
main()


t = int(input())
for _ in range(t):
	len_l = int(input())
	test_l = list(map(int, input().split()))
	test_min = min(test_l)
	print(len_l - test_l.count(test_min))


for i in range(int(input())):
	n = int(input())
	a = sorted(list(map(int, input().split())))
	print(len(a) - a.count(a[0]))


cases = int(input())
for case in range(cases):
	n = int(input())
	a = list(map(int, input().split(' ')))
	minVal = min(a)
	print(len([x for x in a if x > minVal]))


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	c = min(b)
	count = 0
	for i in b:
		if i != c:
			count += 1
	print(count)


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = set(a)
	j = [0, 0]
	for i in b:
		if a.count(i) > j[0]:
			j[0] = a.count(i)
			j[1] = i
	if j[1] > min(a):
		print(n - a.count(min(a)))
	else:
		print(n - j[0])


from sys import stdin as si, stdout as so
for _ in range(int(si.readline())):
	n = int(si.readline())
	a = list(map(int, si.readline().split()))
	d = a.count(min(a))
	so.write(str(n - d) + '\n')


import math, sys, itertools
wtf = sys.stdin.read()
wtf = wtf.strip().split('\n')
for t in [wtf[i:i + 2] for i in range(1, len(wtf), 2)]:
	n = int(t[0])
	A = sorted(list(map(int, t[1].split())))
	if len(A) == 1:
		print(0)
	else:
		print(len([x for x in A if x > (A[0] + A[1]) // 2]))


n = int(input())
for i in range(n):
	m = int(input())
	num = [int(i) for i in input().split()]
	a = min(num)
	c = 0
	for i in num:
		if i != a:
			c += 1
	print(c)


k = []
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	k.append(n - a.count(min(a)))
for i in k:
	print(i)


t = int(input().strip())
for case in range(t):
	n = int(input().strip())
	nums = list(map(int, input().split()))
	count = nums.count(min(nums))
	print(len(nums) - count)


import collections
from collections import defaultdict
import math
from math import ceil
from collections import Counter
for i in range(int(input())):
	n = int(input())
	a = [int(c) for c in input().split()]
	print(n - a.count(min(a)))


n = int(input())
for x in range(n):
	t = int(input())
	a = list(map(int, input().split()))
	a.sort()
	smallest = a[0]
	r = t
	for y in range(t):
		if a[y] == smallest:
			r -= 1
	print(r)


def map_input(type=1):
	if type == 1:
		return map(int, input().split())
	elif type == 2:
		return map(float, input().split())
	elif type == 3:
		return map(str, input().split())
	return None

def list_input(type=1):
	return list(map_input(type))

def sorted_indices(s):
	li = []
	for i in range(len(s)):
		li.append([s[i], i])
	li.sort()
	return [x[1] for x in li]

def floorSearch(arr, x, low=-1, high=-1):
	if low == -1:
		low = 0
	if high == -1:
		high == len(arr) - 1
	if low > high:
		return -1
	if x >= arr[high]:
		return high
	mid = int((low + high) / 2)
	if arr[mid] == x:
		return mid
	if mid > 0 and arr[mid - 1] <= x and (x < arr[mid]):
		return mid - 1
	if x < arr[mid]:
		return floorSearch(arr, low, mid - 1, x)
	return floorSearch(arr, mid + 1, high, x)

def find_index(arr, x):
	low = 0
	high = len(arr) - 1
	mid = 0
	while low <= high:
		mid = (high + low) // 2
		if arr[mid] < x:
			low = mid + 1
		elif arr[mid] > x:
			high = mid - 1
		else:
			return mid
	return -1

def floyd_warshell(g):
	n = len(g)
	d = g.copy()
	for k in range(n):
		for i in range(n):
			for j in range(n):
				d[i][j] = min(d[i][j], d[i][k] + d[k][j])
	return d

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def main():
	for _ in range(int(input())):
		n = int(input())
		a = list_input()
		m = min(a)
		c = a.count(m)
		print(n - c)
try:
	main()
except:
	pass


import bisect
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	le = n
	while le > 0:
		su = sum(l)
		x = su / len(l)
		if x >= l[-1]:
			break
		pin = bisect.bisect_left(l, x)
		l = l[:pin]
		le = len(l)
	print(n - le)


n = int(input())
for i in range(0, n):
	num = int(input())
	ln = input().split()
	ln = [int(j) for j in ln]
	s = sum(ln)
	su = 0
	ave = s / num
	nmin = min(ln)
	sn = ln.count(nmin)
	su = len(ln) - sn
	print(su)


def solve():
	n = int(input())
	a = list(map(int, input().split()))
	b = []
	while a != b:
		x = sum(a) / len(a)
		(b, a) = (a, [q for q in a if q < x + 1e-09])
	print(n - len(a))
x = int(input())
for i in range(x):
	solve()


t = int(input())
ans = []
for i in range(t):
	n = int(input())
	nums = tuple(map(int, input().split()))
	ans.append(n - nums.count(min(nums)))
for case in tuple(ans):
	print(case)


t = int(input())
for _ in range(t):
	n = int(input())
	(*a,) = map(int, input().split())
	a.sort()
	print(len(a) - a.count(min(a)))


T = int(input())
while T > 0:
	count1 = 0
	n = int(input())
	a = list(map(int, input().split()))
	count1 = a.count(min(a))
	if count1 == n:
		print('0')
	else:
		print(n - count1)
	T -= 1