#include <iostream>
usingnamespace std;
int main ()
{
int n;
cin >> n;
int arr[1001] = {0}, check = 0;
for (int i=0; i < n; i++)
{
int a;
cin >> a;
if (a > check)
{
check = a;
}
}
int m = 0, mode = 0;
for (int i = 1; i <= check; i++)
{
if (arr[i] > 0)
{
if (arr[i] > m)
{
m = arr[i];
mode = i;
}
elseif (arr[i] == m & i > mode)
{
m = arr[i];
mode = i;
}
}
}
cout << mode << endl;
return 0;
}