from collections import * from heapq import * 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 H = [] for k, v in D.items(): heappush(H, -v) ans = 0 while len(H) >= 3: a = heappop(H) b = heappop(H) c = heappop(H) a, b, c = -a - 1, -b - 1, -c - 1 ans += 1 if a: heappush(H, -a) if b: heappush(H, -b) if c: heappush(H, -c) print(ans)