#include <bits/stdc++.h>
using namespace std;
int a[300000];
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 300000; i++) {
    a[i] = -1;
  }
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    a[x] = n - i;
  }
  int mx = -2;
  int ans = 0;
  for (int i = 0; i < 300000; i++) {
    if (a[i] > mx) {
      mx = a[i];
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
