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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int t;
    cin >> t;
    while(t--){
        ll n;
        cin >> n;
        ll a[n];
        for(int i = 0 ; i < n ; i++){
            cin >> a[i];
        }
        map<ll, ll> mp;
        
        for(int i = 0 ; i < n ; i++){
            mp[a[i]]++;;
        }
        ll count = 0;
        for(auto x : mp){
            if(x.second > n/2){
                count = x.second - (n - x.second);
            }
        }
        if(count == 0 && n%2 == 1){
            count = 1;
        }
        cout << count << endl;
    }
}