#include <bits/stdc++.h>
        
using namespace std;
    
#define ar array
#define ll long long
    
const int MAX_N = 1e5 + 1;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;

void solve() {

    ll n;
    cin>>n;

    vector<ll> v(n);
    map<ll, ll> umap;
    for(ll i=0;i<n;i++) {
        cin>>v[i];
        umap[v[i]]++;
    }

    priority_queue<pair<ll, ll>> pq;
    for(auto i: umap) {
        pq.push(make_pair(i.second, i.first));
    }

    while(!pq.empty() && (pq.size() >= 2)) {
        pair<ll, ll> p1 = pq.top();
        pq.pop();
        pair<ll, ll> p2 = pq.top();
        pq.pop();

        if(p1.first > 1) {
            pq.push(make_pair(p1.first - 1, p1.second));
        }
        if(p2.first > 1) {
            pq.push(make_pair(p2.first - 1, p2.second));
        }
    }

    ll ans = 0;
    while(!pq.empty()) {
        ans += (pq.top().first);
        pq.pop();
    }

    cout<<ans<<endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    int tc = 1;
    cin >> tc;
    for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        solve();
    }
}