#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long arr[n];
  set<long long> s1, s2;
  for (long long i = 0; i < n; i++) {
    cin >> arr[i];
    s1.insert(arr[i]);
  }
  long long i = n - 1;
  while (i >= 0) {
    s2.insert(arr[i]);
    if (s2.size() == s1.size()) {
      cout << arr[i] << endl;
      break;
    }
    i--;
  }
  return 0;
}
