#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n = 0;
  cin >> n;
  map<int, int> m;
  for (int i = 0; i < n; i++) {
    int aux = 0;
    cin >> aux;
    m[aux] = i;
  }
  int ans = INT_MAX, ans2 = 0;
  for (auto it = m.begin(); it != m.end(); it++) {
    if (it->second < ans) {
      ans2 = it->first;
      ans = it->second;
    }
  }
  cout << ans2 << endl;
  return 0;
}
