#include using namespace std; using ll=long long; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll T; cin>>T; while(T--){ ll N; cin>>N; map L; for(int i=0;i>a; L[a]++; } priority_queue Q; for(auto p:L)Q.push(p.second); ll an=0; while(Q.size()>2){ vector V; for(int i=0;i<3;i++){ V.push_back(Q.top()); Q.pop(); } an++; for(int i=0;i<3;i++){ if(V[i]>1)Q.push(V[i]-1); } } cout<