#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  map<int, int> m;
  int Min = INT_MAX, best;
  for (int i = 0; i < n; i++) cin >> v[i], m[v[i]] = i;
  for (auto x : m)
    if (x.second < Min) Min = x.second, best = x.first;
  cout << best;
}
