#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> was(2 * 100001, -1);
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = n - 1; i >= 0; --i) {
    if (was[a[i]] == -1) was[a[i]] = i;
  }
  int mn = INT32_MAX, ans = -1;
  for (int i = 0; i < was.size(); ++i) {
    if (was[i] != -1 && was[i] < mn) {
      mn = was[i];
      ans = i;
    }
  }
  cout << ans;
}
