#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a, b;
  vector<int> v;
  set<int> s1, s2;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a;
    v.push_back(a);
    s1.insert(a);
  }
  for (int i = n - 1; i >= 0; i--) {
    a = v[i];
    s2.insert(a);
    if (s1.size() == s2.size()) break;
  }
  cout << a << endl;
  return 0;
}
