#include using namespace std; int sol(priority_queue< pair >& pq){ int ans = 0; pair x[3]; while(!pq.empty()) { for(int i = 0; i < 3; i++) { if(pq.empty()) return ans; x[i] = pq.top(); pq.pop(); } for(int i = 0; i < 3; i++) { if (x[i].first > 1) { x[i].first--; pq.push(x[i]); } } ans++; } return ans; } int main() { cin.tie(0); ios::sync_with_stdio(false); int t, n, tmp = 0, count = 1; cin >> t; for(int i = 0; i < t; i++) { cin >> n; vector a(n); priority_queue< pair > pq; for(int j = 0; j < n; j++) { cin >> a[j]; } sort(a.begin(), a.end()); for(int j = 0; j < n; j++) { if (tmp == 0) { tmp = a[j]; } else if (tmp == a[j]) { count++; } else { pq.push(make_pair(count, tmp)); tmp = a[j]; count = 1; } } pq.push(make_pair(count, tmp)); tmp = 0; count = 1; cout << sol(pq) << "\n"; } return 0; }