#include <bits/stdc++.h>

#define f first
#define s second
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double

using namespace std;

int block = 400;
const ll pe = 137;
const ll pe2 = 1181;
const ll INF = 1e18;
const ld eps = 1e-7;
const ll N = 2e6 + 200;
const ll mod = 1e9 + 7;
const ll cmod = 998244353;

int t, n, a[N];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> t;
    while (t--){
        cin >> n;
        int ans = 0, sum = 0;
        map<int, int> was;
        for (int i = 1; i <= n; i++)
            cin >> a[i], ans = max(ans, ++was[a[i]]);
        for (int i = 1; i <= n; i++)
            sum += was[a[i]], was[a[i]] = 0;
        if (sum - ans < ans){
            cout << max(n % 2, ans - sum + ans) << '\n';
        }
        else{
            cout << n % 2 << '\n';
        }
    }
}
