#include #define For(i, a, b) for(int i = a; i < b; i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(int i = a; i >= b; i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; using ld = long double; int INF = 2000000000; lint LINF = 1000000000000000000; int main() { int t; cin >> t; while (t--) { int n; cin >> n; map mp; rep(_, n) { int l; cin >> l; mp[l]++; } set s; for (auto [fi, se] : mp) { if (!s.count(fi)) { s.insert(fi); } } int ans = 0; while ((int)s.size() >= 3) { auto it = s.begin(); int a = *it; it = next(it); int b = *it; it = next(it); int c = *it; ans++; mp[a]--; if (mp[a] == 0) { s.erase(a); } mp[b]--; if (mp[b] == 0) { s.erase(b); } mp[c]--; if (mp[c] == 0) { s.erase(c); } } cout << ans << endl; } }