#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0; i < n; i += 1) cin >> v[i];
  map<int, int> ind;
  for (int i = 0; i < n; i += 1) {
    ind[v[i]] = i;
  }
  int res = -1, curr = INT_MAX;
  for (auto it = ind.begin(); it != ind.end(); ++it) {
    if (it->second < curr) {
      curr = it->second;
      res = it->first;
    }
  }
  cout << res;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
