#yuki_120 from collections import Counter n=int(raw_input()) for i in xrange(n): int(raw_input()) s=Counter(map(int,raw_input().split())).values() s=sorted(s,reverse=True) res=0 if len(s)>=3: while True: if s[0] and s[1] and s[2]: s[0]-=1 s[1]-=1 s[2]-=1 res+=1 else: s=sorted(s,reverse=True) if s[2]==0: break print res