#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, x;
  cin >> n;
  vector<long long> v, v2;
  set<long long> st, st2;
  for (int i = 0; i < n; i++) {
    cin >> x;
    st.insert(x);
    v.push_back(x);
  }
  for (int i = n - 1; i >= 0; i--) {
    v2.push_back(v[i]);
    st2.insert(v[i]);
    if (st2.size() == st.size()) break;
  }
  cout << v2.back() << "\n";
  return 0;
}
