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

#define For(i,a,b)      for(i = a; i < b; i++)
#define Forr(i,a,b)     for(i = a; i <= b; i++)
#define MFor(i,a,b)     for(i = a; i > b; i--)
#define MForr(i,a,b)    for(i = a; i >= b; i--)
#define ll              long long
#define yes             cout << "YES\n"
#define no              cout << "NO\n"
#define endl            "\n"
#define MX              100000
#define space           " "

int main(){
    ll t, n;
    cin >> t;
    while(t--){
        ll c = 1, ans = 0, i, d, maxx = 0;
        cin >> n;
        ans = n;
        ll arr[n+5];
        Forr(i,1,n) cin >> arr[i];
        sort(&arr[1], &arr[n+1]);
        //Forr(i,1,n) cout << arr[i] << space;
        Forr(i,2,n){
            if(arr[i] == arr[i-1]) c++;
            else c = 1;
            if(c > maxx) maxx = c;
        }
        c = maxx;
        if(c <= n/2){
            if((n & 1) == 0) cout << "0\n";
            else cout << "1\n";
        }
        else{
           d = (n - c) * 2;
           cout << n - d << endl;
        }
    }
}

