#include <bits/stdc++.h>
using namespace std;
int a[500001], n, l[500001], r = -1;
int main() {
  ios::sync_with_stdio(0);
  for (int i = 0; i < 500001; i++) l[i] = -1;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    l[a[i]] = i;
  }
  for (int i = 0; i < 500001; i++) {
    if ((l[i] > -1) && ((r == -1) || (l[i] < l[r]))) {
      r = i;
    }
  }
  cout << r;
  return 0;
}
