$n$ heroes fight against each other in the Arena. Initially, the $i$-th hero has level $a_i$.

Each minute, a fight between two different heroes occurs. These heroes can be chosen arbitrarily (it's even possible that it is the same two heroes that were fighting during the last minute).

When two heroes of equal levels fight, nobody wins the fight. When two heroes of different levels fight, the one with the higher level wins, and his level increases by $1$.

The winner of the tournament is the first hero that wins in at least $100^{500}$ fights (note that it's possible that the tournament lasts forever if no hero wins this number of fights, then there is no winner). A possible winner is a hero such that there exists a sequence of fights that this hero becomes the winner of the tournament.

Calculate the number of possible winners among $n$ heroes.


-----Input-----

The first line contains one integer $t$ ($1 \le t \le 500$) — the number of test cases.

Each test case consists of two lines. The first line contains one integer $n$ ($2 \le n \le 100$) — the number of heroes. The second line contains $n$ integers $a_1, a_2, \dots, a_n$ ($1 \le a_i \le 100$), where $a_i$ is the initial level of the $i$-th hero.


-----Output-----

For each test case, print one integer — the number of possible winners among the given $n$ heroes.


-----Examples-----

Input
3
3
3 2 2
2
5 5
4
1 3 3 7
Output
1
0
3


-----Note-----

In the first test case of the example, the only possible winner is the first hero.

In the second test case of the example, each fight between the heroes results in nobody winning it, so the tournament lasts forever and there is no winner.

Source: codeforces | Difficulty: EASY
Tags: Sorting

Implementation


Solutions:
for _ in range(int(input())):
	n = int(input())
	a = [int(i) for i in input().split()]
	a.sort()
	wins = 0
	for i in range(n):
		if a[i] > a[0]:
			wins += 1
	print(wins)


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


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


import sys
read = sys.stdin.readline
write = lambda x, end='\n': sys.stdout.write(x + end)
for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = min(l)
	print(sum((x != m for x in l)))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	s = set(l)
	if len(s) == 1:
		print(0)
	else:
		print(len(l) - l.count(min(s)))


for _ in range(int(input())):
	n = int(input())
	levels = [int(x) for x in input().split()]
	leastLevel = min(levels)
	leastLevelCount = levels.count(leastLevel)
	if leastLevelCount == n:
		print(0)
	else:
		print(n - leastLevelCount)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	Min = min(a)
	flag = False
	a.sort()
	for i in range(n):
		if a[i] != Min:
			print(n - i)
			flag = True
			break
	if not flag:
		print(0)


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


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


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


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	ans = 0
	for i in a:
		if not i == a[0]:
			ans += 1
	print(ans)


T = int(input())
for testcase in range(1, T + 1):
	n = int(input())
	l = input().split()
	a = [int(i) for i in l]
	a.sort()
	i = 1
	while i < len(a) and a[i] == a[0]:
		i += 1
	print(n - i)


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


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


from pprint import pprint
import sys
input = sys.stdin.readline

def do():
	n = int(input())
	dat = list(map(int, input().split()))
	mix = min(dat)
	res = 0
	for x in dat:
		if x > mix:
			res += 1
	print(res)
q = int(input())
for _ in range(q):
	do()


T = int(input())
for t in range(T):
	n = int(input())
	strengths = list(map(int, input().strip().split()))[:n]
	print(len(strengths) - strengths.count(min(strengths)))


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
from math import log
sa = lambda : input()
sb = lambda : int(input())
sc = lambda : input().split()
sd = lambda : list(map(int, input().split()))
se = lambda : float(input())
sf = lambda : list(input())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7

def hnbhai():
	n = sb()
	a = sd()
	ans = len(a) - a.count(min(a))
	print(ans)
for _ in range(sb()):
	hnbhai()


t = int(input())

def get_answer(n, a):
	a.sort()
	i = 0
	while i < n - 1:
		if a[i + 1] > a[i]:
			break
		i += 1
	return n - i - 1
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	print(get_answer(n, a))


t = int(input())
for _ in range(t):
	n = int(input())
	fi = list(map(int, input().split()))
	cnt = 0
	fi.sort()
	for i in range(1, n):
		if len(list(filter(lambda x: x < fi[i], fi[0:i]))) > 0:
			cnt += 1
	print(cnt)


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


for test in range(int(input())):
	h = int(input())
	p = list(map(int, input().split()))
	print(h - p.count(min(p)))


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


try:
	t = int(input())
	for i in range(t):
		n = int(input())
		a = list(map(int, input().split()))
		a = sorted(a)
		pos = -1
		for i in range(1, len(a)):
			if a[i] != a[i - 1]:
				pos = i
				break
		if pos != -1:
			ans = len(a) - pos
		else:
			ans = 0
		print(ans)
except:
	pass


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	a.sort()
	c = 0
	if a[0] == a[-1]:
		print('0')
		continue
	for i in range(1, n):
		if a[i - 1] != a[i]:
			c = i
			break
	print(n - i)


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


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


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input().split()
	arr = [int(i) for i in s]
	min1 = min(arr)
	count = 0
	for i in arr:
		if i != min1:
			count += 1
	print(count)


tests = int(input())
for t in range(tests):
	n = int(input())
	heroes = list(map(int, input().split(' ')))
	m = min(heroes)
	print(sum([1 for x in heroes if x > m]))


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = lambda : sys.stdin.buffer.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	q = sorted(list(map(int, input().split())))
	t = -1
	for i in range(n):
		if q[i] != q[0]:
			t = i
			break
	if t == -1:
		print(0)
	else:
		print(n - t)


def solve(answs):
	input()
	a = [int(x) for x in input().split(' ')]
	m = min(a)
	w = 0
	for h in a:
		if h > m:
			w += 1
	answs.append(w)
times = int(input())
answs = []
for i in range(times):
	solve(answs)
for a in answs:
	print(a)


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


for _ in range(int(input())):
	input()
	participants = list(map(int, input().split()))
	participants.sort()
	winners = 0
	min_level = participants[0]
	start_post = 0
	for i in range(len(participants)):
		if min_level != participants[i]:
			start_post = i
			break
	if start_post == 0:
		print(0)
	else:
		print(len(participants[start_post:]))


t = int(input())
heroes = []
for i in range(t):
	n = input()
	temp = input()
	l = temp.split(' ')
	l = [int(x) for x in l]
	heroes.append(l)
for j in range(len(heroes)):
	winners = 0
	sort = sorted(heroes[j])
	for i in range(len(sort)):
		value = sort[i]
		if value > sort[0]:
			winners = winners + 1
	print(winners)


import sys

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

def inp_lst():
	return list(map(int, sys.stdin.readline().strip().split()))
t = int_inp()
for _ in range(t):
	n = int_inp()
	l = inp_lst()
	print(n - l.count(min(l)))


import sys
sys.setrecursionlimit(4000)
import math
from collections import Counter
from collections import defaultdict
from collections import deque
input = sys.stdin.readline
import heapq

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
n = inp()
for k in range(n):
	m = inp()
	arr = inlt()
	arr.sort()
	count = 0
	l = arr[0]
	for i in arr:
		if i == l:
			count += 1
		else:
			break
	print(m - count)


t = int(input())
results = []
for i in range(t):
	n = int(input())
	heroes = list(map(int, input().split()))
	heroes.sort()
	count = 0
	while heroes[count] == heroes[count + 1]:
		count += 1
		if count == n - 1:
			break
	results.append(n - count - 1)
for i in range(t):
	print(results[i])


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


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


import sys
pin = sys.stdin.readline
for T in range(int(pin())):
	N = int(pin())
	A = [*map(int, pin().split())]
	mm = min(A)
	print(N - A.count(mm))


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


from sys import stdin, stdout, setrecursionlimit
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log, log2
from random import seed, randint
from datetime import datetime
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
from collections import defaultdict as dd
mod = pow(10, 9) + 7
mod2 = 998244353

def inp():
	return stdin.readline().strip()

def iinp():
	return int(inp())

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

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

def lmp():
	return list(mp())

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

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

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

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

def remadd(x, y):
	return 1 if x % y else 0

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

def def_value():
	return 0
for _ in range(iinp()):
	n = iinp()
	a = lmp()
	print(n - a.count(min(a)))


for _ in range(int(input())):
	n = int(input())
	l = sorted(list(map(int, input().split())))
	k = min(l)
	try:
		while l[0] == k:
			l.remove(k)
	except:
		l = []
	print(len(l))


n = int(input())
for i in range(n):
	ni = int(input())
	hs = [int(inp) for inp in input().split()]
	hs.sort()
	winners = []
	for i2 in range(ni):
		for i3 in range(ni):
			if hs[i2] > hs[i3] and i2 != i3 and (i2 not in winners):
				hs[i2] += 1
				winners.append(i2)
	print(len(winners))


import sys

def get_arr():
	return list(map(int, sys.stdin.readline().strip().split()))
t = int(input())
for i in range(t):
	n = int(input())
	arr = get_arr()
	if max(arr) == min(arr):
		print(0)
	else:
		count = 0
		for j in arr:
			if j == min(arr):
				count += 1
		print(len(arr) - count)


num = int(input())
for i in range(num):
	lenz = int(input())
	arr = input()
	arr = arr.split(' ')
	arr = [int(x) for x in arr]
	minn = min(arr)
	if arr.count(minn) == len(arr):
		print(0)
	else:
		print(len(arr) - arr.count(minn))


import os
import sys
from io import BytesIO, IOBase

def func(heros):
	return len(heros) - sum([1 for hero in heros if hero == min(heros)])

def main():
	num_test = int(parse_input())
	for _ in range(num_test):
		num_hero = int(parse_input())
		heros = [int(i) for i in parse_input().split()]
		print(func(heros))
parse_input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


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


T = int(input())
for _ in range(T):
	N = int(input())
	A = [int(a) for a in input().split()]
	print(len(A) - A.count(min(A)))


from sys import stdin, stdout
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = [int(x) for x in input().split()]
	m = min(a)
	ans = 0
	for i in a:
		if i != m:
			ans += 1
	print(ans)


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


def Codeforces():
	for _ in range(int(input())):
		n = int(input())
		arr = list(map(int, input().split()))
		arr.sort(reverse=True)
		x = arr.pop()
		while arr and arr[-1] == x:
			arr.pop()
		print(len(arr))
Codeforces()


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


from math import sqrt, ceil

def seive(n):
	x = [0, 0] + [i for i in range(2, n + 1)]
	for i in range(4, n + 1, 2):
		x[i] = 0
	for i in range(3, int(sqrt(n)) + 1, 2):
		if x[i]:
			for j in range(i * i, n + 1, i):
				x[j] = 0
	x = list(filter(lambda : y != 0, x))
	return x

def binexp(a, b, mod=10 ** 9 + 7):
	if b == 0:
		return 1
	sq = binexp(a, b // 2, mod)
	if b & 1:
		return a * (sq * sq) % mod % mod
	return sq * sq % mod
R = lambda : list(map(int, input().split()))
for _ in ' ' * int(input()):
	n = R()[0]
	a = R()
	m = min(a)
	print(n - a.count(m))


from collections import Counter, defaultdict, OrderedDict, deque
from bisect import bisect_left, bisect_right
from functools import reduce, lru_cache
from typing import List
import itertools
import sys
import math
import heapq
import string
import random
(MIN, MAX, MOD) = (-1061109567, 1061109567, 1000000007)

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())
for _ in range(int(input())):
	n = N()
	a = RLL()
	a.sort()
	for i in range(1, n):
		if a[i] != a[0]:
			break
	print(n - i if a[-1] != a[0] else 0)


def helper(arr):
	arr.sort(reverse=True)
	flag = True
	while flag:
		if len(arr) == 2 and arr[0] == arr[1]:
			return 0
		if len(arr) < 2:
			break
		if arr[-1] != arr[-2]:
			flag = False
		arr.pop()
	ans = len(arr)
	return ans
test = int(input())
for i in range(test):
	l = int(input())
	inp = list(map(int, input().split()))
	ans = helper(inp)
	print(ans)


from math import *

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


for i in range(int(input())):
	a = int(input())
	b = list(map(int, input().split()))
	b.sort()
	count = 0
	for j in range(a):
		if b[j] == b[0]:
			count += 1
		else:
			break
	print(a - count)


t = int(input())
for i in range(t):
	number = int(input())
	levels = list(map(int, input().strip().split()))
	levels.sort()
	count = 0
	for j in levels:
		if levels[0] == j:
			count += 1
		else:
			break
	print(number - count)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		levels = list(map(int, input().split()))
		levels.sort()
		min_val = levels[0]
		min_cnt = 0
		for val in levels:
			if val == min_val:
				min_cnt += 1
			else:
				break
		print(len(levels) - min_cnt)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	line = input()
	res = [int(i) for i in line.split()]
	mm = min(res)
	cnt = sum([1 for i in res if i == mm])
	res = len(res) - cnt
	print(res)


for i in range(int(input())):
	n = int(input())
	(a, d) = (list(map(int, input().split())), {})
	a.sort(reverse=True)
	for j in a:
		if j not in d:
			d[j] = 1
		else:
			d[j] += 1
	print(n - d[a[-1]])


test_case = int(input())
for tc in range(0, test_case):
	n = int(input())
	arr = list(map(int, input().split()))
	mn = min(arr)
	ans = 0
	for i in range(0, n):
		if arr[i] != mn:
			ans += 1
	print(ans)


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


def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		hero = list(map(int, input().split()))
		mini = 0
		hero_min = hero[0]
		for hr in hero:
			if hr == hero_min:
				mini += 1
			elif hr < hero_min:
				hero_min = hr
				mini = 1
		print(n - mini)
main()


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print('0')
	else:
		k = min(a)
		cnt = a.count(k)
		print(n - cnt)


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	k = min(a)
	s = 0
	for j in a:
		if j > k:
			s += 1
	print(s)


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


t = int(input())
for k in range(t):
	n = int(input())
	heroes = sorted(list(map(int, input().split())))
	if len(set(heroes)) == 1:
		print(0)
	else:
		for (i, hero) in enumerate(heroes):
			if hero > heroes[0]:
				print(n - i)
				break


for _ in range(int(input())):
	n = int(input())
	li = list(map(int, input().split()))
	li.sort()
	tmp = li[0]
	res = 0
	for i in li:
		if i > tmp:
			res += 1
	print(res)


n = int(input())
for i in range(n):
	input()
	f = list(map(int, input().split()))
	ctr = 0
	m = min(f)
	for j in f:
		if j > m:
			ctr += 1
	print(ctr)


import sys
import math
import bisect
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')
for T in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	ans = 0
	for i in a:
		if i != m:
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr)
	mini = min(arr)
	count = 0
	for i in arr:
		if i != mini:
			count += 1
	print(count)


t = int(input())
while t:
	n = int(input())
	a = list(map(int, input().split()))
	b = min(a)
	out = 0
	for i in a:
		if i > b:
			out += 1
	print(out)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	A = list(map(int, input().split()))
	A.sort()
	a1 = A[0]
	d = 0
	for j in range(len(A)):
		if a1 != A[j]:
			d = j
			break
	if d != 0:
		print(len(A) - d)
	else:
		print(0)


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


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


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


for _ in range(int(input())):
	n = int(input())
	arr = list(map(int, input().split()))
	arr_set = set(arr)
	if len(arr_set) == 1:
		print(0)
	else:
		print(len(arr) - arr.count(min(arr_set)))


def main():
	t = int(input())
	for __ in range(t):
		n = int(input())
		a = sorted(list(map(int, input().split())))
		i = 1
		count = 0
		while i < n:
			if a[i] != a[0]:
				count += 1
			i += 1
		print(count)
main()


for t in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	if len(set(a)) == 1:
		print(0)
	else:
		print(n - a.count(min(a)))


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort(reverse=1)
	ans = temp = 0
	for i in range(n):
		if i == 0:
			temp += 1
			continue
		if l[i] == l[i - 1]:
			temp += 1
		else:
			ans += temp
			temp = 1
	print(ans)


s = input()
while True:
	try:
		s = input()
		t = sorted(list(map(int, input().split(' '))))
		l = 0
		for i in range(len(t)):
			if t[i] != t[0]:
				l += 1
		print(l)
	except:
		break


t = int(input())
for i in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	cnt = 0
	min_elem = min(a)
	for i in range(len(a)):
		if min_elem < a[i]:
			cnt += 1
	print(cnt)


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


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


for _ in range(int(input())):
	a = int(input())
	l = [int(i) for i in input().split()]
	l.sort()
	x = l[0]
	cnt = 0
	ans = 0
	for i in range(a):
		if l[i] != x:
			print(a - cnt)
			ans = 1
			break
		cnt += 1
	if ans == 0:
		print(0)


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	Q = n
	i = 0
	while i < n:
		if a[i] == m:
			Q -= 1
		i += 1
	print(Q)


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


from sys import stdin, stdout
from os import path
rd = lambda : stdin.readline().strip()
wr = stdout.write
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
import time
for _ in range(int(rd())):
	x = int(rd())
	mylist = list(map(int, rd().split()))
	mn = min(mylist)
	counter = 0
	for i in mylist:
		if i > mn:
			counter += 1
	print(counter)


def count_winners(heroes):
	heroes.sort()
	winners = dict()
	count = 0
	for i in range(1, len(heroes)):
		if heroes[i] > heroes[i - 1] or heroes[i] in winners:
			count += 1
			winners[heroes[i]] = 0
	return count

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		heroes = list(map(int, input().split()))
		print(count_winners(heroes))
main()


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


for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	a.sort()
	min_value = min(a)
	while min_value in a:
		a.remove(min_value)
	print(len(a))


t = int(input())
while t > 0:
	t -= 1
	n = input()
	a = list(map(int, input().split(' ')))
	min_a = min(a)
	amin = list(map(lambda x: x - min_a, a))
	filter_amin = list(filter(lambda x: x > 0, amin))
	print(len(filter_amin))


from sys import stdin as IN
t = int(input())
for _ in range(t):
	n = int(input())
	h = sorted(map(int, next(IN).split()), reverse=True)
	ans = 0
	lower = len(set(h)) - 1
	prev = h[0]
	for i in h:
		if i != prev:
			lower -= 1
		if lower:
			ans += 1
		prev = i
	print(ans)


for t in range(int(input())):
	n = int(input())
	l = [*map(int, input().split())]
	m = min(l)
	cnt = 0
	for i in l:
		cnt += i != m
	print(cnt)


import sys
input = sys.stdin.readline

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


def check(nums, n):
	mini = min(nums)
	maxi = max(nums)
	count = 0
	for i in range(n):
		if nums[i] == mini:
			pass
		else:
			count += 1
	return count
for _ in range(int(input())):
	n = int(input())
	nums = list(map(int, input().split()))
	nums = sorted(nums)
	print(check(nums, n))


def read_ints():
	return map(int, input().split())
(t_n,) = read_ints()
for i_t in range(t_n):
	(a_n,) = read_ints()
	a_seq = tuple(read_ints())
	result = len(a_seq) - a_seq.count(min(a_seq))
	print(result)


for i in range(int(input())):
	n = int(input())
	heroes = [int(x) for x in input().split(' ')]
	if heroes == [heroes[0] for j in range(n)]:
		print(0)
		continue
	min = 101
	c = 0
	for i in range(len(heroes)):
		if heroes[i] < min:
			min = heroes[i]
			c = heroes.count(min)
	print(len(heroes) - c)


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


for _ in range(int(input())):
	n = int(input())
	a = [int(x) for x in input().split()]
	mini = min(a)
	ans = 0
	for i in a:
		if i > mini:
			ans += 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	min = l[0]
	for i in l:
		if i < min:
			min = i
	final = list()
	for i in range(n):
		if l[i] == min:
			continue
		else:
			final.append(l[i])
	print(len(final))


t = int(input())
ansl = []
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	ansl.append(n - l.count(min(l)))
for e in ansl:
	print(e)


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


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 nCk(n, k):
	res = 1
	for i in range(1, k + 1):
		res = res * (n - i + 1) // i
	return res
for _ in range(int(input())):
	n = int(input())
	arr = sorted(list(map(int, input().split())))
	i = 0
	while i < n and arr[i] == arr[0]:
		i += 1
	print(n - i)


import sys
T = int(input())
for test_case in range(T):
	n = int(input())
	heroes = list(map(int, sys.stdin.readline().rstrip().split()))
	heroes.sort()
	index = -1
	for i in range(1, len(heroes)):
		if heroes[i] != heroes[i - 1]:
			index = i
			break
	if index == -1:
		print(0)
	else:
		print(len(heroes) - index)


def solution():
	t = int(input())
	out = ''
	while t > 0:
		n = int(input())
		a = list(map(int, input().split(' ')))
		a.sort()
		cnt = a.count(a[0])
		out = out + str(n - cnt) + '\n'
		t -= 1
	print(out)
solution()


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


for _ in range(int(input())):
	n = int(input())
	heroes = list(map(int, input().split()))
	lowest = min(heroes)
	highest = max(heroes)
	while lowest in heroes:
		heroes.remove(lowest)
	ans = len(heroes)
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(map(int, input().split()))
	l.sort()
	y = l.pop(0)
	count = 0
	for i in l:
		if i > y:
			count += 1
	print(count)


def solution():
	n = int(input())
	a = [int(i) for i in input().split()]
	(min_a, k) = (101, 0)
	for i in a:
		if i < min_a:
			min_a = i
			k = 1
		elif i == min_a:
			k += 1
	print(n - k)
for t in range(int(input())):
	solution()


n = int(input())
for i in range(n):
	t = int(input())
	x = list(map(int, input().split()))
	a = 101
	l = 0
	for i in range(len(x)):
		if x[i] < a:
			a = x[i]
	for i in range(len(x)):
		if x[i] == a:
			l = l + 1
	print(t - l)


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


for i in range(int(input())):
	l = input()
	r = []
	k = list(map(int, input().split()))
	h = set(k)
	k.sort()
	q = k[0]
	r.append(len(h) - 1)
	if len(h) != 1:
		for j in h:
			if j != q:
				r.append(k.count(j))
			else:
				continue
		print(sum(r) - (len(h) - 1))
	else:
		print('0')


for _ in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	m = max(l)
	n = min(l)
	if m == n:
		print(0)
	else:
		print(len(l) - l.count(n))


import math
import sys
import os.path
if os.path.exists('input_file.txt'):
	sys.stdin = open('input_file.txt', 'r')
	sys.stdout = open('output_file.txt', 'w')
for i in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	c = 0
	for i in a:
		if m != i:
			c += 1
	print(c)


import sys

def solve():
	_ = int(sys.stdin.readline().rstrip())
	heros = list(map(int, sys.stdin.readline().rstrip().split(' ')))
	m = min(heros)
	res = 0
	for x in heros:
		res += x > m
	print(res)
t = int(sys.stdin.readline().rstrip())
for _ in range(t):
	solve()


from sys import stdin, stdout

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

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	n = INI()
	X = INL()
	OPS(n - X.count(min(X)))


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


for q in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	m = min(l)
	for i in range(n):
		if l[i] > m:
			c += 1
	print(c)


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


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


def solve(n, ls):
	ans = 0
	mi = min(ls)
	for l in ls:
		if l > mi:
			ans += 1
	return ans
t = int(input())
while t:
	n = int(input())
	ls = list(map(int, input().split()))
	print(solve(n, ls))
	t -= 1


for test in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	slaby = min(a)
	silny = max(a)
	if silny == slaby:
		print(0)
	else:
		print(len(a) - a.count(slaby))


from collections import Counter

def main():
	cases = int(input())
	ans_list = []
	for _ in range(cases):
		n = int(input())
		levels = list(map(int, input().split(' ')))
		ans_list.append(n - Counter(levels)[min(levels)])
	print('\n'.join(map(str, ans_list)))
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')
main()


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


rn = lambda : int(input())
rns = lambda : map(int, input().split())
rl = lambda : list(map(int, input().split()))
rs = lambda : input()
YN = lambda x: print('YES') if x else print('NO')
mod = lambda x: x % (10 ** 9 + 7)

def d(a):
	d = {}
	for i in a:
		if i not in d:
			d[i] = 0
		d[i] += 1
	return d
for _ in range(rn()):
	n = rn()
	a = rl()
	ans = 0
	m = min(a)
	for i in a:
		if i != m:
			ans += 1
	print(ans)


def STR():
	return list(input())

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

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

def MAP2():
	return map(float, input().split())

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

def STRING():
	return input()
import string
import sys
from heapq import heappop, heappush
from bisect import *
from collections import deque, Counter, defaultdict
from math import *
from itertools import permutations, accumulate
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
for tt in range(INT()):
	n = INT()
	arr = LIST()
	mn = min(arr)
	cnt = 0
	for i in arr:
		if i > mn:
			cnt += 1
	print(cnt)


t = int(input())
for i in range(t):
	n = int(input())
	s = list()
	inp = input()
	freq = dict()
	for num in inp.strip().split():
		if int(num) in freq:
			freq[int(num)] = freq[int(num)] + 1
		else:
			freq[int(num)] = 1
		s.append(int(num))
	s.sort()
	print(len(s) - freq[s[0]])


t = int(input())
s2 = []
for i in range(t):
	k = 0
	n = int(input())
	s = list(map(int, input().split()))
	a = min(s)
	for j in range(len(s)):
		if s[j] > a:
			k += 1
	s2.append(k)
for h in range(len(s2)):
	print(s2[h])


import sys
stdint = lambda : int(sys.stdin.readline())
readintlist = lambda : [int(i) for i in sys.stdin.readline().split()]
stdwrite = lambda line: sys.stdout.write(line + '\n')
t = stdint()
while t:
	n = stdint()
	li = readintlist()
	mi = min(li)
	mi_c = 0
	for i in li:
		if i == mi:
			mi_c += 1
	stdwrite(str(n - mi_c))
	t -= 1


num_tests = int(input())
for _ in range(num_tests):
	a = input()
	nums = sorted(map(int, input().split()))
	print(len([n for n in nums if n != nums[0]]))


t = int(input())
for i in range(t):
	n = int(input())
	arr = list(map(int, input().split()))
	arr = sorted(arr, reverse=True)
	ans = 0
	for i in range(len(arr)):
		for j in range(i, len(arr)):
			if arr[i] > arr[j]:
				arr[i] -= 1
				ans += 1
				break
	print(ans)


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


for i in range(int(input())):
	a = int(input())
	l = list(map(int, input().split()))
	ans = set(l)
	new = []
	if len(ans) == 1:
		print('0')
		continue
	else:
		kep = min(l)
		for t in l:
			if kep != t:
				new.append(t)
	print(len(new))


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from functools import cmp_to_key
from heapq import *
from math import gcd, factorial, floor, ceil, sqrt, log2
from copy import deepcopy
from collections import deque
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

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 testcase(t):
	for pp in range(t):
		solve(pp)

def google(p):
	print('Case #' + str(p) + ': ', end='')

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

def power(x, y, p):
	y %= p - 1
	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 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
inf = pow(10, 20)
mod = 10 ** 9 + 7

def solve(case):
	n = int(inp())
	a = lis()
	mn = min(a)
	ans = 0
	for i in range(n):
		if a[i] != mn:
			ans += 1
	print(ans)
testcase(int(inp()))


t = int(input())
for _ in range(t):
	n = input()
	winners = 0
	champs = [int(x) for x in input().split(' ')]
	for lvl in champs:
		if lvl > min(champs):
			winners += 1
	print(winners)


T = int(input())
for t in range(T):
	N = int(input())
	P = list(map(int, input().split()))
	P.sort(reverse=True)
	i = 0
	conta = 0
	while i < len(P):
		j = i + 1
		while j < len(P) and P[i] == P[j]:
			j = j + 1
		if j < len(P):
			conta += j - i
			i = j - 1
		i += 1
	print(conta)


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


t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	minvalue = min(a)
	ans = sum(map(lambda x: 1 if x > minvalue else 0, a))
	print(ans)


import math
for _ in range(int(input())):
	n = int(input())
	a = list(map(int, input().split()))
	b = min(a)
	c = 0
	for d in a:
		if d > b:
			c += 1
	print(c)


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


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


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


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


import sys
import math
input = sys.stdin.readline
t = int(input())
for w in range(t):
	n = int(input())
	l = [int(i) for i in input().split()]
	c = 0
	i = 0
	j = 0
	s = 0
	print(n - l.count(min(l)))


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	l = list(map(int, stdin.readline().split()))
	m = l.sort()
	p = l[0]
	c = l.count(p)
	print(n - c)


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


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


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 i in range(t):
	n = int(input())
	lst = list(map(int, input().split(' ')))
	s = sorted(lst)
	a = s.count(s[0])
	l = len(lst)
	b = l - a
	print(b)


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


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	a = list(map(int, input().split()))
	m = min(a)
	ans = 0
	for x in a:
		if x > m:
			ans += 1
	print(ans)


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


from itertools import combinations, count

def issame(lst):
	if len(lst) < 0:
		res = True
	res = lst.count(lst[0]) == len(lst)
	if res:
		return True
	else:
		return False
for _ in range(int(input())):
	n = int(input())
	ar = list(map(int, input().split(' ')))
	ans = set()
	if issame(ar):
		print(0)
	else:
		for i in range(len(ar)):
			for j in range(len(ar)):
				if i != j:
					if ar[i] > ar[j]:
						ans.add((i, ar[i]))
					elif ar[i] < ar[j]:
						ans.add((j, ar[j]))
					else:
						continue
		print(len(ans))


t = int(input())
for q in range(t):
	n = int(input())
	ch = input()
	L = [int(i) for i in ch.split()]
	L.sort()
	nb = 0
	for i in range(1, n):
		if L[i] > L[0]:
			nb += 1
	print(nb)


T = int(input())
while T > 0:
	T = T - 1
	n = int(input())
	arr = list(map(int, input().split()))
	arr.sort()
	ct1 = arr.count(arr[0])
	if ct1 == n:
		print(0)
	else:
		print(n - ct1)


for t in range(int(input())):
	n = int(input())
	l = sorted(map(int, input().split()))
	ans = 0
	for i in range(1, n):
		if l[0] != l[i]:
			ans = n - i
			break
	print(ans)


def solve():
	n = int(input())
	mas = list(map(int, input().split()))
	m = min(mas)
	print(len(list(filter(lambda x: x != m, mas))))
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	heroes = [int(j) for j in input().split()]
	heroes.sort()
	maybe_winrs = 0
	weak = heroes[0]
	for j in range(1, n):
		if heroes[j] > weak:
			maybe_winrs += 1
	print(maybe_winrs)


for i in range(int(input())):
	n = int(input())
	l = list(map(int, input().split()))
	c = 0
	for i in range(n):
		cnt = 0
		for j in range(n):
			if l[i] > l[j]:
				l[i] += 1
				cnt += 1
		if cnt > 0:
			c += 1
	print(c)


import math
import sys

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

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

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

def solve():
	n = int(input())
	a = getlist()
	amin = min(a)
	coun = a.count(amin)
	print(n - coun)
for _ in range(int(input())):
	solve()


cases = int(input())
while cases:
	cases -= 1
	num = int(input())
	arr = list(map(int, input().split()))
	x = min(arr)
	y = arr.count(x)
	print(len(arr) - y)


import os
import sys
from math import *
from collections import *
from bisect 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'
M = 998244353
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

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()]
for _ in range(Int()):
	n = Int()
	a = array()
	a.sort()
	ans = n - a.count(a[0])
	print(ans)


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

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

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

def insr():
	s = input()
	return list(s[:len(s) - 1])

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

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

def seive(n):
	primes = [True] * (n + 1)
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	return primes

def factors(n):
	factors = []
	x = 2
	while x * x <= n:
		while n % x == 0:
			factors.append(x)
			n //= x
		if n > 1:
			factors.append(x)
	return factors

def main():
	try:
		for _ in range(inp()):
			n = inp()
			a = inlt()
			mn = min(a)
			ans = 0
			for i in range(n):
				if a[i] != mn:
					ans += 1
			print(ans)
	except Exception as e:
		print(e)
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 sys
T = int(input())
for case in range(T):
	n = int(input())
	a = sorted(list(map(int, sys.stdin.readline().split())))
	print(sum((1 for x in a if x > a[0])))


for tc in range(int(input())):
	N = int(input())
	A = list(map(int, input().split()))
	ans = 0
	mn = min(A)
	for i in A:
		if i > mn:
			ans += 1
	print(ans)


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


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		a = list(map(int, stdin.readline().split(' ')))
		m = min(a)
		a = list(filter(lambda x: x != m, a))
		stdout.write(str(len(a)) + '\n')
main()


t = int(input())
n = []
cnt = 0
for _ in range(t):
	cnt = 0
	n.append(int(input()))
	g = list(map(int, input().split()))
	m = min(g)
	for i in g:
		if i > m:
			cnt += 1
	print(cnt)


def fun(ls):
	mn = min(ls)
	l = sorted(ls)
	count = 0
	for (i, val) in enumerate(l[1:]):
		if l[i - 1] < val or val > mn:
			count += 1
	print(count)
T = int(input())
for i in range(T):
	t = int(input())
	ls = list(map(int, input().split()))
	fun(ls)


import sys
for _ in range(int(sys.stdin.readline())):
	n = int(sys.stdin.readline())
	hero = list(map(int, sys.stdin.readline().strip().split()))
	m = min(hero)
	numWinner = n
	for h in hero:
		if h == m:
			numWinner -= 1
	print(numWinner)