#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define FOR(I,A,B) for(int I = (A); I < (B); ++I) typedef long long ll; int main(){ int T; cin >> T; while(T--) { int N; cin >> N; vector L(N); map M; FOR(i,0,N) { cin>>L[i]; M[L[i]]++; } int ans = 0; priority_queue Q; for(auto x : M) Q.push(x.second); if(M.size()>=3) { while(!Q.empty()) { int a = Q.top();Q.pop(); int b = Q.top();Q.pop(); int c = Q.top();Q.pop(); if (c <= 0) break; ans++; Q.push(a-1); Q.push(b-1); Q.push(c-1); } } printf("%d\n", ans); } }