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

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