#include<iostream>
#include<vector>
using namespace std;
int main() {
int N = 0;
int mtemp = 0;
int max = 0;
int temp = 0;
int number = 0;
cin >> N;
vector<int> arr(N);
vector<int> grade(N);
for (int i = 0; i < N; i++)
{
cin >> arr[i];
}
for (int i = 0; i < N; i++)
{
max = arr[i];
mtemp = i;
for (int j = i; j < N; j++)
{
if (max < arr[j])
{
max = arr[j];
mtemp = j;
}
}
temp = arr[i];
arr[i] = arr[mtemp];
arr[mtemp] = temp;
if (i > 0)
{
if(arr[i]==arr[i-1])
{
continue;
}
else
{
grade[number] = arr[i];
number++;
}
}
else
{
grade[number] = arr[i];
number++;
}
}
cout << grade[2];
}