#include<bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,a,b) for(int i=a;i<b;i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int main() {
    IOS
    int t;
    cin>>t;
    while(t--){
        ll n;
        cin>>n;
        ll arr[n];
        rep(i,n) cin>>arr[i];
        map<ll,ll> m;
        rep(i,n) m[arr[i]]++;
        ll maxm=0,smaxm,f,s;
        for(auto itr:m){
        	maxm=max(maxm,itr.second);
		}
		if(maxm<=n/2){
			if(n%2==0) cout<<0<<"\n";
			else cout<<1<<"\n";
			continue;
		}
        ll ans=2*maxm-n;
		cout<<ans<<"\n";
    }
    return 0;
}
