program Apparel;
{$APPTYPE CONSOLE}
uses
  SysUtils;
var
  tests, test: integer;
  a: array[1..100] of integer;
  n, i, c: integer;
  imax, count: integer;
begin
  assign(input, 'apparel.in');
  reset(input);
  //assign(output, 'apparel.out');
  //rewrite(output);

  read(tests);
  for test := 1 to tests do
  begin
    read(n);
    assert((n >= 1) and (n <= 10000), 'Assert!!!');

    for i := 1 to 100 do
      a[i] := 0;

    for i := 1 to n do
    begin
      read(c);
      assert((c >= 1) and (c <= 100), 'Assert');
      a[c] := a[c] + 1;
    end;

    imax := 1;
    count := 1;
    for i := 2 to 100 do
    begin
      if a[i] > a[imax] then
      begin
        imax := i;
        count := 1;
      end
      else if a[i] = a[imax] then
      begin
        count := count + 1;
      end;
    end;

    if (count = 1) then
      writeln(imax)
    else
      writeln(0);
  end;

  close(input);
  //close(output);
end.
 