#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return b;
}
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> used(200001);
  int mx = -1;
  for (int i = 1; i <= n; ++i) {
    int a;
    cin >> a;
    used[a] = i;
  }
  int mi = -1;
  for (int i = 0; i < used.size(); ++i) {
    if (used[i] == 0) {
      continue;
    } else {
      if (n - used[i] > mx) {
        mi = i;
        mx = n - used[i];
      }
    }
  }
  cout << mi;
  return 0;
}
