from collections import Counter import heapq T = int(input()) for _ in range(T): N = int(input()) L = Counter(map(int, input().split())).values() V = [-x for x in L] heapq.heapify(V) ans = 0 tmp_lst = [0] * 3 while True: try: for i in range(3): tmp_lst[i] = heapq.heappop(V) ans += 1 except IndexError: print(ans) break for i in range(3): if tmp_lst[i] < -1: heapq.heappush(V, tmp_lst[i] + 1)