#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  vector<pair<int, bool>> a(n, {0, false});
  set<int> v;
  for (int i = 0; i < n; ++i) {
    cin >> a[i].first;
    v.insert(a[i].first);
  }
  for (int i = n - 1; i >= 0; --i) {
    if (v.size() == 1) {
      break;
    }
    if (!a[i].second) {
      a[i].second = true;
      v.erase(a[i].first);
    }
  }
  for (auto i : v) {
    cout << i;
  }
}
