#include using namespace std; void F(){ int n; cin >> n; vector v(n); long long sum=0; map mp; for(int i=0;i> v[i]; sum+=v[i]; mp[v[i]]++; } priority_queue pq; for(auto i : mp){ pq.push(i.second); } if(mp.size() < 3){ cout << 0 << endl; return; } int ans=0; while(true){ int a=pq.top(); pq.pop(); int b=pq.top(); pq.pop(); int c=pq.top(); pq.pop(); if(c<=0){ cout << ans << endl; return; } ans++; pq.push(a-1); pq.push(b-1); pq.push(c-1); } } int main(){ int t; cin >> t; while(t--){ F(); } return 0; }