#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k = 0, c = 0, n;
  map<int, int> mp;
  map<int, int>::iterator it;
  scanf("%d", &n);
  int a[n];
  for (i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    mp[a[i]] = i;
  }
  k = n;
  for (it = mp.begin(); it != mp.end(); it++) {
    if (it->second < k) {
      k = it->second;
      j = it->first;
    }
  }
  printf("%d\n", j);
}
