#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<long long> f(2000006, -1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    f[a[i]] = i;
  }
  long long ans = 1e18, res;
  for (int i = 0; i <= 2000005; i++) {
    if (f[i] < 0) continue;
    if (ans > f[i]) {
      res = i;
    }
    ans = min(f[i], ans);
  }
  cout << res << endl;
}
