#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, res;
  cin >> n;
  int arr[n + 1];
  set<int> s;
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
    s.insert(arr[i]);
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s.count(arr[i])) {
      res = arr[i];
      s.erase(arr[i]);
    }
    if (s.empty()) break;
  }
  cout << res << endl;
  return 0;
}
