#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
 
int main() {
cin.tie(NULL);
cout.tie(NULL);
ios_base::sync_with_stdio(false);    
 
ll t;
cin>>t;
while(t--){
    ll n,i;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)cin>>a[i];
    map<ll, ll> m; 
    for (i=0; i<n; i++)m[a[i]]++;
    ll maxx=0,sum=0;
    for (auto j=m.begin(); j!=m.end(); j++){
        maxx=max(maxx,j->second);
        sum+=j->second;
    }
    if(sum-maxx>maxx && n%2==0)cout<<"0"<<endl;
    else if(sum-maxx>maxx && n%2!=0)cout<<"1"<<endl;
    else cout<<2*maxx-sum<<endl;
    //for (auto j=m.begin(); j!=m.end(); j++) cout<<j->first<<" "<<j->second<<endl;
    
}
 
return 0;
}