#include<iostream>
#include<string.h>
using namespace std;
int main()
{
int n,i,t,cnt,result;
while(~scanf("%d",&n))
{
cnt=0;
for(i=0;i<n;i++)
{
scanf("%d",&t);
if(cnt==0)
{
cnt=1;
result=t;
}
else
{
if(t==result) cnt++;
else cnt--;
}
}
printf("%d\n",result);
}
return 0;
}