#include <bits/stdc++.h>
using namespace std;

#define ll long long


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll t;
	cin >> t;
	while (t--)
	{
		ll n;
		cin >> n;
		ll a[n];
		map<ll, ll> mp;
		for (ll i = 0; i < n; i++)
		{
			cin >> a[i];
			mp[a[i]]++;
		}

		ll mx=0;
		for(auto x:mp)
		{
           mx=max(mx,x.second);
		}
		if(mx<=n/2)
		{
			cout<<(n%2==0?0:1)<<endl;
		}
		else
		{
			ll ans=(n%2==0)?(mx- (n/2))*2 :(mx-(n/2))*2 -1;
			cout<<ans<<endl;
		}

	}
	return 0;
}