#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
const long double PI = 3.141592653589793238;
void solve() {
  long long n, x;
  cin >> n;
  map<long long, long long> v;
  for (long long i = 0; i < (n); i++) {
    cin >> x;
    v[x] = i + 1;
  }
  long long mn = LONG_LONG_MAX, ans = 0;
  for (auto it = v.begin(); it != v.end(); it++)
    if (it->second > 0 && mn > it->second) ans = it->first, mn = it->second;
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long tc = 1;
  while (tc--) solve();
  return 0;
}
