#include <bits/stdc++.h>
using namespace std;
const long long N = 2 * (1e5) + 5;
long long n, a[N], us[N], mx = N * N, ans;
vector<long long> v;
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  for (int i = n; i >= 1; i--) {
    if (i > us[a[i]]) {
      us[a[i]] = i;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (us[a[i]] < mx) {
      mx = us[a[i]];
      ans = a[i];
    }
  }
  cout << ans;
}
