#include<cstdio>
int read(){
int x=0;char ch=getchar();
while (ch>'9'||ch<'0') ch=getchar();
while (ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
return x;
}
int n,flag,cnt;
int main()
{
freopen("hztp.in","r",stdin);
freopen("hztp.out","w",stdout);
n=read();
for (int i=1;i<=n;i++){
int a=read();
if (!cnt) flag=a;
if (a==flag) cnt++;else cnt--;
}
printf("%d\n",flag);
return 0;
}