#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int arr[200001];
  fill(arr, arr + 200001, n + 1);
  int input;
  for (int i = 0; i < n; i++) {
    cin >> input;
    arr[input] = i;
  }
  int min_num = n + 1;
  int min_at = 0;
  for (int i = 0; i < 200001; i++) {
    if (arr[i] < min_num) {
      min_num = arr[i];
      min_at = i;
    }
  }
  cout << min_at << "\n";
}
