#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, k, T = 0;
  cin >> n;
  map<int, int> seen;
  for (int i = 0; i < n; i++) {
    cin >> k;
    seen[k] = ++T;
  }
  int ans, ti = INT_MAX;
  map<int, int>::iterator it = seen.begin();
  for (; it != seen.end(); it++) {
    if (it->second < ti) {
      ti = it->second;
      ans = it->first;
    }
  }
  cout << ans << '\n';
  return 0;
}
