from collections import Counter from heapq import * T = int(input()) for t in range(T): N = int(input()) L = list(map(int, input().split())) H = [] heapify(H) counted = Counter(L) for n in counted: heappush(H, (-counted[n], n)) count = 0 while len(H) >= 3: count += 1 c1, n1 = heappop(H) c2, n2 = heappop(H) c3, n3 = heappop(H) if c1 < -1: heappush(H, (c1+1, n1)) if c2 < -1: heappush(H, (c2+1, n2)) if c3 < -1: heappush(H, (c3+1, n3)) #print(H) print(count)