#include <bits/stdc++.h>
using namespace std;
int a[(int)2e6];
map<int, int> m;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    m[a[i]] = i;
  }
  int mx = 0, ans;
  for (auto x : m) {
    if (mx == 0 || mx > x.second) {
      ans = x.first;
      mx = x.second;
    }
  }
  cout << ans;
}
