program zht;
var
n,m,i,j,y,s,z,ss:longint;
w,p:array[1..10000] of longint;
begin
assign(input,'leader.in');
assign(output,'leader.out');
reset(input);
rewrite(output);
readln(n,m);
s:=1;
read(z);
p[s]:=p[s]+1;
w[s]:=z;
for i:=2 to m do
begin
read(z);
y:=0;
for j:=1 to s do
if z=w[j] then begin p[j]:=p[j]+1;y:=1;break;end;
if y=1 then continue else begin s:=s+1;w[s]:=z;p[s]:=p[s]+1;end;
end;
for i:=1 to s do
if p[i]>(m div 2) then begin writeln(w[i]);ss:=1;break;end;
if ss=0 then writeln('-1');
close(input);
close(output);
end.