#include <bits/stdc++.h>
using namespace std;
int main() {
  int *a = new int[200001];
  int n;
  cin >> n;
  for (int i = 0; i < 200001; i++) {
    a[i] = -1;
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x] = i;
  }
  int r = 1000000;
  int resi = -1;
  for (int i = 0; i < 200001; i++) {
    if (a[i] != -1 && a[i] < r) {
      resi = i;
      r = a[i];
    }
  }
  cout << resi;
  return 0;
}
