#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a;
  cin >> n;
  int was[2 * 100 * 100 * 10 + 1];
  fill(was, was + 2 * 100 * 100 * 10 + 2, n + 2);
  for (int i = 0; i < n; i++) {
    cin >> a;
    was[a] = i;
  }
  int ans = 0;
  for (int i = 0; i < 2 * 100 * 100 * 10 + 1; i++) {
    if (was[i] < was[ans]) {
      ans = i;
    }
  }
  cout << ans;
  return 0;
}
