#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  unordered_set<int> s;
  vector<int> v(n);
  for (int &x : v) cin >> x, s.insert(x);
  unordered_map<int, int> mp;
  for (int i = n - 1; i >= 0; i--) {
    if (s.count(v[i]) || mp[v[i]] > 0) mp[v[i]]++, s.erase(v[i]);
    if (s.empty()) {
      cout << v[i] << "\n";
      return 0;
    }
  }
}
