#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
ll solve(vector <int> &a)
{
    ll n = a.size();
    sort(a.begin(), a.end());
    vector <int> cnt;
    ll c = 1;
    for(int i=1; i<n; i++){
        if(a[i] == a[i-1]) c++;
        else{
            cnt.pb(c);
            c = 1;
        }
    }
    cnt.pb(c);
    sort(cnt.begin(), cnt.end());
    reverse(cnt.begin(), cnt.end());
    return cnt[0];
}
 
int main()
{
    ll t;
    cin >> t;
    while(t--){
        ll n, ans = 0;
        cin >> n;
        vector <int> arr(n);
        for(int i=0; i<n; i++) cin >> arr[i];
        if(n%2) ans = 1;
        ll a = solve(arr);
        if(a <= n/2)
            cout << ans << "\n" ;
        else cout << 2*a - n << "\n";
    }
}