#include <bits/stdc++.h>
using namespace std;
template <typename _T>
inline void _DBG(const char* s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char* s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}
template <typename type>
istream& operator>>(istream& in, vector<type>& a);
template <typename type>
ostream& operator<<(ostream& out, const vector<type>& a);
ostream& operator<<(ostream& out, const vector<int>& a);
ostream& operator<<(ostream& out, const vector<double>& a);
template <typename type1, typename type2>
ostream& operator<<(ostream& out, const pair<type1, type2>& a);
template <typename type1, typename type2>
istream& operator>>(istream& in, pair<type1, type2>& a);
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  map<int, int> lastind;
  for (int i = 0; i < n; ++i) {
    lastind[a[i]] = i;
  }
  int ans = a[0];
  int res = lastind[a[0]];
  for (auto& x : lastind) {
    if (x.second < res) {
      ans = x.first;
      res = x.second;
    }
  }
  cout << ans << endl;
  return 0;
}
template <typename type1, typename type2>
istream& operator>>(istream& in, pair<type1, type2>& a) {
  in >> a.first >> a.second;
  return in;
}
template <typename type1, typename type2>
ostream& operator<<(ostream& out, const pair<type1, type2>& a) {
  out << a.first << " " << a.second;
  return out;
}
ostream& operator<<(ostream& out, const vector<double>& a) {
  for (auto& x : a) {
    out << x << " ";
  }
  return out;
}
ostream& operator<<(ostream& out, const vector<int>& a) {
  for (auto& x : a) {
    out << x << " ";
  }
  return out;
}
template <typename type>
ostream& operator<<(ostream& out, const vector<type>& a) {
  for (auto& x : a) {
    out << x << endl;
  }
  return out;
}
template <typename type>
istream& operator>>(istream& in, vector<type>& a) {
  for (auto& x : a) {
    in >> x;
  }
  return in;
}
