#include <bits/stdc++.h>
using namespace std;
signed main() {
  int n;
  cin >> n;
  vector<int> ans, arr(n);
  unordered_set<int> ar;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    ar.insert(arr[i]);
  }
  int sz = (int)ar.size();
  ar.clear();
  for (int i = n - 1; i >= 0; i--) {
    if (ar.find(arr[i]) == ar.end()) {
      ans.push_back(arr[i]);
      ar.insert(arr[i]);
    }
    if ((int)ans.size() == sz) break;
  }
  cout << ans.back() << "\n";
  return 0;
}
