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