program leader;
type node=record num,ans:longint; end;
var
a:array[1..10000]of node;
n,m,num,ans,head,i,j:longint;
f:boolean;
begin
assign(input,'leader.in');reset(input);
assign(output,'leader.out');rewrite(output);
readln(n,m);
read(a[1].num);
a[1].ans:=1;
head:=1;
for i:=2 to m do
begin
read(num);
f:=true;
for j:=1 to head do
if a[j].num=num then begin inc(a[j].ans); f:=false; break; end;
if f then begin inc(head); a[head].num:=num; a[head].ans:=1; end;
end;
ans:=-1;
for i:=1 to head do
if a[i].ans>m div 2 then begin ans:=a[i].num; break; end;
writeln(ans);
close(input);close(output);
end.