#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int a[200005] = {0};
  int res = 0;
  for (int i = 1; i <= n; i++) {
    cin >> res;
    a[res] = i;
  }
  for (int i = 0; i < 200005; i++) {
    if (a[res] > a[i] && a[i] != 0) res = i;
  }
  cout << res;
  return 0;
}
