#include <bits/stdc++.h>
using namespace std;
constexpr int N = 2 * 1e5 + 1;
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(N, 0);
  for (int i = 0, cur; i < n; ++i) {
    cin >> cur;
    a[cur] = i + 1;
  }
  int minn = 1e9, ans = -1;
  for (int i = 0; i < a.size(); ++i) {
    if (a[i] && minn > a[i]) minn = min(minn, a[i]), ans = i;
  }
  cout << ans;
}
