from heapq import heapify from collections import defaultdict T=int(input()) for _ in range(T): N=int(input()) L=list(map(int,input().split())) D=defaultdict(int) for a in L: D[a]+=1 Q=list(D.keys()) heapify(Q) X=0 while len(Q)>=3: p=Q.pop() q=Q.pop() r=Q.pop() X+=1 for x in [p,q,r]: D[x]-=1 if D[x]>=1: Q.append(x) print(X)