#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x>T; while(T--) { cin>>N; map M; FOR(i,N) cin>>x, M[x]++; vector V; ITR(it,M) V.push_back(it->second); sort(V.begin(),V.end()); int ret=0; int H=V.size(); if(H>=3) { while(V[H-3]) { V[H-1]--; V[H-2]--; V[H-3]--; ret++; sort(V.begin(),V.end()); } } cout<