#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, q, k = 0;
  cin >> n;
  map<long long, long long> a;
  for (auto(i) = (0); (i) < (n); (i)++) {
    cin >> q;
    a[q] = i;
  }
  long long o = 1000000007, c;
  for (auto e : a) {
    if (e.second < o) {
      c = e.first;
      o = e.second;
    }
  }
  cout << c;
  return 0;
}
