t = int(input()) for i in range(t): n = int(input()) a = list(map(int,input().split())) print(max(a.count(1),a.count(0)))