# -*- coding: utf-8 -*- def calc(Alist, M): Alist.sort() Alist.append(0) maxK = M // 3 max1 = 0 max2 = 0 cnt = 1 ccc = 1 for i in range(1, M+1): if Alist[i] == Alist[i-1]: cnt += 1 elif Alist[i] != Alist[i-1]: ccc += 1 if max1 <= cnt: max2 = max1 max1 = cnt if max2 < cnt < max1: max2 = cnt cnt = 1 if maxK < max1: M -= (max1 - maxK) maxK = M // 3 if maxK < max2: M -= (max2 - maxK) maxK = M // 3 if ccc <= 2: maxK = 0 return maxK Alist = [] out = [] L = input() for i in range(0, L): M = input() Alist = map(int, raw_input().split()) out.append(calc(Alist, M)) for i in range(0, L): print out[i]