#include <bits/stdc++.h>
using namespace std;
const int INF = (1 << 31) - 1;
const long long LINF = (1ll << 63) - 1;
const double DINF = numeric_limits<double>::infinity();
const int MOD = 1e9 + 7;
const double EPS = 1e-7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
mt19937 mmtw(MOD);
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(mmtw) % (y - x + 1) + x;
}
template <class T>
T binpow(T n, T k) {
  if (k == 1) return n;
  if (k & 1) return binpow(n, k - 1) * n;
  T a = binpow(n, k / 2);
  return a * a;
}
template <class T>
T fact(T n) {
  if (n == 1) return 1;
  return n * fact(n - 1);
}
const int MAXN = 2e5 + 5;
int q;
int n;
int last[MAXN];
int main() {
  cin >> n;
  for (int i = 0; i < MAXN; ++i) {
    last[i] = INF;
  }
  for (int i = 0; i < n; ++i) {
    cin >> q;
    last[q] = i;
  }
  int mn = 0;
  for (int i = 0; i < MAXN; ++i) {
    if (last[i] < last[mn]) {
      mn = i;
    }
  }
  cout << mn << endl;
}
