T = int(input()) from collections import Counter from heapq import * for _ in range(T): n = int(input()) a = map(int,input().split()) d = Counter(a) *s, = sorted(-v for k,v in d.items()) ans = 0 heapify(s) while len(s) >= 3: ans += 1 x = heappop(s) y = heappop(s) z = heappop(s) if x <= -2: heappush(s,x+1) if y <= -2: heappush(s,y+1) if z <= -2: heappush(s,z+1) print(ans)