import java.util.*;
public class tyt
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int[] a=new int[n];
for (int i = 0; i < n; i++)
{
a[i]=(in.nextInt());
}
for (int i = 0; i < n; i++)
{
int min = 0;
int max = 0;
for(int j=0;j<n;j++)
{
if (i != j)
{
if (a[j] > a[i])
{
max++;
}
else if(a[j]<a[i])
{
min++;
}
}
}
if (min == max)
{
System.out.println(a[i]);
return;
}
else if(i==n-1)
{
System.out.println(-1);
}
}
}
}