#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  map<int, int> used;
  int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (used[a[i]] == 0) {
      used[a[i]] = i;
      ans = a[i];
    }
  }
  cout << ans;
  return 0;
}
