def main(): ct = int(input()) for i in range(ct): input() a = [int(b) for b in input().split()] b = {} for c in a: if c not in b: b[c] = 0 b[c] += 1 d = [(e, b[e]) for e in b] d.sort(key=lambda x: x[1], reverse=True) oth = len(a)-d[0][1] print(max(d[0][1] - oth, len(a)%2)) main()