// In the name of ALLAH, The Most Gracious and The Most Merciful
// Muhammad Abdur Rahman Muaj
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lln ll n;cin>>n;
#define vl vector<ll>
#define vln vector<ll>a(n);
#define vs vector<string>
#define pb push_back
#define pp pop_back
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yno (f?"YES":"NO");
#define f(x) for(ll i=0; i<x; i++)
#define f1(x) for(ll i=1;i<=x;i++)
#define fo(o,x) for(ll i=o;i<x;i++)
#define fla f(n)cin>>a[i];
#define sumall(a) accumulate(begin(a),end(a),0);
#define so(x) sort(x.begin(), x.end());
#define revsort(x) sort(x.begin(), x.end(), std::greater<int>());
#define mem(a,b) memset(a, b, sizeof(a) )
int main(){
lln
vln
fla
so(a)
ll c=0;
f(n){
if(a[i]!=a[i+1]){
if(a[i]!=a[i-1]){c=a[i];break;}
else continue;
}
}
cout<<c;
}