var
a:array[0..10000]of longint;
n,i,m,ans,mid,sum,max:longint;
procedure sort(l,r:longint);
var i,j,m,t:longint;
begin
i:=l;j:=r;m:=a[(l+r)div 2];
repeat
while a[i]<m do inc(i);
while a[j]>m do dec(j);
if i<=j then
begin
t:=a[i];a[i]:=a[j];a[j]:=t;
inc(i);dec(j);
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
begin
assign(input,' leader.in');
reset(input);
assign(output,'leader.out');
rewrite(output);
readln(n,m);
for i:=1 to m do read(a[i]);
sort(1,m);
mid:=n div 2;
for i:=1 to m do
begin
if a[i]=a[i+1]then inc(sum) else if sum>max then begin max:=sum;ans:=a[i];end;
end;
if ans>mid then writeln(ans)else writeln(-1);
close(input);close(output);
end.