import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import Counter from heapq import heapify, heappop, heappush T = int(readline()) def get_test_case(): N = int(readline()) *L, = map(int,readline().split()) return N,L def solve_test_case(N,L): A = list(Counter(L).values()) A = [-x for x in A] heapify(A) # 多いのを3つ作る、を繰り返す n = 0 while len(A) >= 3: n += 1 a,b,c = [heappop(A) for _ in range(3)] a += 1 b += 1 c += 1 for x in [a,b,c]: if x < 0: heappush(A,x) return n cases = [get_test_case() for _ in range(T)] for N,L in cases: print(solve_test_case(N,L))