import heapq import collections T=int(input()) for _ in range(T): N = int(input()) L = collections.Counter(list(map(int, input().split()))) q = [100-v for k,v in L.items()] cnt = 0 while len(q)>=3: a = heapq.heappop(q) b = heapq.heappop(q) c = heapq.heappop(q) cnt += 1 if a<100: heapq.heappush(q,a+1) if b<100: heapq.heappush(q,b+1) if c<100: heapq.heappush(q,c+1) print(cnt)