// pro hai hum
// shubham_kr
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//Naive Solution as follows...
#include<bits//stdc++.h>
#include<cmath>
#include<vector>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
using namespace std;
#define fri(n) for(i=0;i<n;i++)
#define frj(n) for(j=0;j<n;j++)
int main()
{   
    int t;
    cin>>t;
    while(t--)
    {
      int n;
      cin>>n;
     map<int,int> ma;
      int x=0,i;
      fri(n)
      {    
          int v;
          cin>>v;
          if(ma.find(v)==ma.end())
           ma.insert({v,1});
           else
             ma[v]++;
         if(ma[v]>x)
           x=ma[v];
      }
           if(x<=n/2)
       {
           if(n%2==0)
            cout<<0<<endl;
            else
            cout<<1<<endl;
       }
       else
       {
           cout<<abs(n-2*x)<<endl;
       }
    }
    return 0;
}


 

