#include <bits/stdc++.h>
const long long INF = 1e18;
using namespace std;
void SOE(long long n) {
  bool isPrime[n + 1];
  memset(isPrime, true, sizeof(isPrime));
  for (long long p = 2; p <= n; p++) {
    if (isPrime[p]) {
      for (long long i = p * p; i <= n; i += p) isPrime[i] = false;
    }
  }
}
long long POWER(long long base, long long expo) {
  long long num = 1;
  long long i = expo;
  while (i) {
    num = num * base;
    i--;
  }
  return num;
}
int main() {
  long long t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n + 1];
    set<long long> s, check;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i];
      s.insert(a[i]);
    }
    long long x = s.size();
    for (long long i = n; i >= 1; i--) {
      check.insert(a[i]);
      if (check.size() == x) {
        cout << a[i];
        return 0;
      }
    }
  }
  return 0;
}
