from collections import Counter from heapq import heapify as hpi , heappop as hpop , heappush as hpush t=int(input()) for i in range(t): n=int(input()) a=list(map(int,input().split())) c=[-i for i in Counter(a).values()] hpi(c) cnt=0 while len(c) >= 3: x=hpop(c)+1 y=hpop(c)+1 z=hpop(c)+1 for i in [x,y,z]: if i != 0: hpush(c,i) cnt+=1 print(cnt)