#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    ll t,n;
    cin>>t;
    while(t--){
       cin>>n;
       ll ar[n];
       map<ll,ll>f;
       for(int i=0;i<n;i++){
           cin>>ar[i];
           f[ar[i]]++;
       }
       set<ll>s1;
       priority_queue<ll>p;
       for(int i=0;i<n;i++){
           s1.insert(ar[i]);
       }
       for(auto it: s1){
           p.push(f[it]);
       }
       while(p.size()>=2){
           ll a = p.top();
           a--;
           p.pop();
           ll b = p.top();
           b--;
           p.pop();
           if(a>0) {
               p.push(a);
           }
           if(b>0){
               p.push(b);
           }
       }
       ll ans=0;
        while(!p.empty()){
            ans+=p.top();
            p.pop();
        }
        cout<<ans<<"\n";
    }
    return 0;
}