#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  map<int, int> record;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    record[x] = i;
  }
  int y = record.begin()->second;
  int z = record.begin()->first;
  map<int, int>::iterator itr;
  for (itr = record.begin(); itr != record.end(); itr++) {
    if (itr->second < y) {
      y = itr->second;
      z = itr->first;
    }
  }
  cout << z;
  return 0;
}
