#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<long long, long long> M;
  long long t;
  for (int i = 0; i < n; i++) {
    cin >> t;
    M[t] = i;
  }
  long long cur = n + 1;
  long long ans = 0;
  for (auto elem : M) {
    if (elem.second < cur) {
      cur = elem.second;
      ans = elem.first;
    }
  }
  cout << ans << '\n';
  return 0;
}
