#include "bits/stdc++.h" #define REP(i,n,N) for(ll i=(n); i<(N); i++) #define RREP(i,n,N) for(ll i=(N-1); i>=n; i--) #define CK(n,a,b) (a)<=(n)&&(n)<(b) #define ALL(v) (v).begin(),(v).end() #define p(s) cout<<(s)<>T){ REP(t,0,T){ int N; cin>>N; int ans=0; map m; REP(i,0,N){ int l; cin>>l; m[l]++; } priority_queue pq; for(auto mm:m){ pq.push(mm.second); } while(pq.size()>2){ int a=pq.top(); pq.pop(); int b=pq.top(); pq.pop(); int c=pq.top(); pq.pop(); if(c==0) break; ans++; a--; b--; c--; pq.push(a); pq.push(b); pq.push(c); } p(ans); } } }