#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n;
  vector<int> mass(n);
  m = 0;
  for (int i = 0; i < n; i++) {
    cin >> mass[i];
    if (m < mass[i]) {
      m = mass[i];
    }
  }
  m++;
  vector<int> last(m, -1);
  for (int i = 0; i < n; i++) {
    last[mass[i]] = i + 1;
  }
  int Min = 9999999;
  int Index = -1;
  for (int i = 0; i < m; i++) {
    if (last[i] != -1 && last[i] < Min) {
      Min = last[i];
      Index = i;
    }
  }
  if (Index != -1) {
    cout << Index;
  } else {
    cout << 0;
  }
  return 0;
}
