#include <bits/stdc++.h>
int main() {
  int n, i;
  int max = 0;
  scanf("%d", &n);
  int arr[n];
  int arr2[200005];
  for (i = 0; i < 200005; i++) arr2[i] = -1;
  for (i = 0; i < n; i++) {
    scanf("%d", &arr[i]);
    arr2[arr[i]] = i;
    if (arr[i] > max) max = arr[i];
  }
  int min = n;
  for (i = 0; i <= max; i++) {
    if (arr2[i] > -1) {
      if (arr2[i] < min) min = arr2[i];
    }
  }
  printf("%d", arr[min]);
  return 0;
}
