#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, lst;
  cin >> n;
  int ara[400003], cnt[400003];
  for (int i = 1; i <= n; i++) cin >> ara[i];
  for (int i = n; i >= 1; i--) {
    cnt[ara[i]]++;
    if (cnt[ara[i]] == 1) lst = ara[i];
  }
  cout << lst;
  return 0;
}
