#include <bits/stdc++.h>
using namespace std;
int main() {
  int a[200001];
  int n, p, st = 0;
  cin >> n;
  for (int k = 0; k < 200001; k++) a[k] = -1;
  for (int k = 0; k < n; k++) {
    cin >> p;
    a[p] = k;
  }
  int mind = 300000;
  for (int k = 0; k < 200001; k++) {
    if (a[k] < mind && a[k] != -1) {
      mind = a[k];
      st = k;
    }
  }
  cout << st;
  return 0;
}
