#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef long long ll;
typedef pair<int, int> pii;
#define sz(x) (int)(x).size()
#define all(x) x.begin(), x.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
ll powmod(ll a,ll b) {ll res=1; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a;a=a*a;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

void solve() {
    int n,a;
    cin >> n;
    map<int,int> pre;
    for(int i=0;i<n;++i) {
        cin >> a;
        pre[a]++;
    }
    vector<int> v;
    for(auto it: pre) v.pb(it.S);
    sort(all(v));
    int del = 0,cur=v.back();
    if(cur > n/2) {
        cout << 2*cur-n << '\n';
    } else {
        int ans = 0;
        if(n&1) ans=1;
        cout << ans << '\n';
    }
}


int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); 
    int t,Tc=1;
    cin>>t;
    while(t--){
      //  cout << "Case #"<<Tc<<": "; Tc++;
        solve();
    }
  return 0;
}