def solve(N, L): L.sort() used = -1 res = 0 for st in range(len(L)): prev = L[st] cnt = 0 for i in range(st, len(L)): if L[i] == used: continue if cnt == 0 or L[i] != prev: cnt += 1 prev = L[i] L[i] = used if cnt == 3: res += 1 break if cnt < 3: break return res T = int(input()) lis = [0] * T for tt in range(T): nt = int(input()) lt = [int(x) for x in input().split()] lis[tt] = solve(nt, lt) print(*lis, sep='\n')