#include #include using namespace std; int main() { int T; cin>>T; while (T--) { int n; cin>>n; map a; while (n--) { int l; cin>>l; a[l]++; } int res=0; while (a.size()>2) { map::iterator i=a.begin(); decltype(i) j=i; ++j; decltype(i) k=j; ++k; i->second--; if (i->second==0) a.erase(i); j->second--; if (j->second==0) a.erase(j); k->second--; if (k->second==0) a.erase(k); ++res; } cout<