#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define REP(i, a) for (int i(0); i < (a); ++i)
#define FOR(i, a, b) for (int i(a); i <= (b); ++i)

#ifdef LOCAL
#include <mydebug.h>
#else
#define debug(...)
#endif

using namespace std;
using ll = long long;

void solve() {
  int n;
  cin >> n;
  map<int, int> m;
  REP(i, n) {
    int x;
    cin >> x;
    ++m[x];
  }
  set<pair<int, int>, greater<pair<int, int>>> s;
  for (auto &[k, v] : m) {
    s.insert({v, k});
  }

  int ans = n;
  while (m.size() > 1) {
    ans -= 2;
    auto st = *s.begin();
    auto nd = *next(s.begin());
    s.erase(st);
    s.erase(nd);

    if (int now = --m[st.S]; now == 0) {
      m.erase(st.S);
    } else {
      s.insert({now, st.S});
    }

    if (int now = --m[nd.S]; now == 0) {
      m.erase(nd.S);
    } else {
      s.insert({now, nd.S});
    }
  }
  cout << ans << "\n";
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);

  int T = 1;
  cin >> T;
  while (T--) {
    solve();
  }
}
