#include <bits/stdc++.h>
#pragma comment(linker, "/stack:20000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")
using namespace std;
const int N = 1100;
const int MAXN = int(1e6) + 100;
const int Mmask = (1 << 20);
const int mod = int(1e9) + 7;
const long long MOD = (long long)(1e18) + 7ll;
int solution();
int main(int argc, char* const argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  return solution();
}
int n, a[MAXN], cnt[MAXN];
pair<int, int> ans;
int solution() {
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    cnt[a[i]] = i;
  }
  ans.first = n;
  ans.second = a[n];
  for (int i = 1; i <= n; i++) {
    if (cnt[a[i]] < ans.first) {
      ans.first = cnt[a[i]];
      ans.second = a[i];
    }
  }
  cout << ans.second;
  return 0;
}
