# 3つの数が異なれば門松列は作れる # ある数が多数ある場合はそれから使うのがいい T = int(input()) for t in range(T): N = int(input()) L = list(map(int, input().split())) from collections import Counter counted = Counter(L) from heapq import * H = [] heapify(H) for n in counted: heappush(H, -counted[n]) ans = 0 while True: if len(H) < 3: break else: k1 = heappop(H) k2 = heappop(H) k3 = heappop(H) ans += 1 if k1 < -1: heappush(H, k1+1) if k2 < -1: heappush(H, k2+1) if k3 < -1: heappush(H, k3+1) #print('ans', ans, 'H', H) print(ans)