#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
void pass() { return; }
const double EPS = 1e-6;
mt19937 rnd(time(NULL));
const long long MOD = 1e9 + 7;
const long long BIG_MOD = 1e18 + 7;
const long long MAXN = 2e5 + 7;
long long a[MAXN];
signed main() {
  cout.precision(20);
  ios_base::sync_with_stdio(false);
  long long n;
  cin >> n;
  for (long long i = 0; i < n; ++i) {
    cin >> a[i];
  }
  long long ans = -1;
  set<long long> s;
  for (long long i = n - 1; i >= 0; --i) {
    if (s.find(a[i]) == s.end()) {
      ans = a[i];
    }
    s.insert(a[i]);
  }
  cout << ans;
  return 0;
}
