from collections import Counter t = int(input()) for i in range(t): n = int(input()) l = list(map(int, input().split())) c = 0 while True: counter = Counter(l) if len(counter) < 3: break for t in counter.most_common(3): l.remove(t[0]) c += 1 print(c)