#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> mapuh;
  for (int i = 0; i < n; i++) {
    int index;
    cin >> index;
    mapuh[index] = i;
  }
  map<int, int>::iterator it;
  pair<int, int> min;
  for (it = mapuh.begin(); it != mapuh.end(); it++) {
    if (it == mapuh.begin()) {
      min = pair<int, int>(it->first, it->second);
    } else {
      if (it->second < min.second) {
        min = *it;
      }
    }
  }
  cout << min.first;
  return 0;
}
