#include <bits/stdc++.h>
bool cmp(std::pair<int, int> a, std::pair<int, int> b) {
  if (a.first > b.first)
    return false;
  else if (a.first == b.first and a.second < b.second)
    return false;
  return true;
}
template <class ForwardIt>
void print_vec(ForwardIt first, ForwardIt last) {
  while (first != last) {
    std::cout << "(" << first->first << ", " << first->second << ") ";
    ++first;
  }
  std::cout << std::endl;
}
int main() {
  int n, a;
  std::vector<std::pair<int, int>> likes(1000000, std::make_pair(0, 0));
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    std::cin >> a;
    likes[a - 1] = std::make_pair(likes[a - 1].first + 1, i);
  }
  std::cout << std::max_element(likes.begin(), likes.end(), cmp) -
                   likes.begin() + 1
            << std::endl;
  return 0;
}
