#include <bits/stdc++.h>
using namespace std;
int a[200000 + 1];
int n;
int b[200000 + 1];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    b[a[i]] = 0;
  }
  int max = -1;
  int k = 0;
  int numb;
  for (int i = n; i > 0; i--) {
    k = 0;
    if (b[a[i]] == 0) {
      b[a[i]] = 1;
      k = n - i;
    }
    if (k > max) {
      max = k;
      numb = a[i];
    }
  }
  cout << numb;
  return 0;
}
