#include <bits/stdc++.h>
using namespace std;
void dfs(long long u, vector<long long> &marked, vector<long long> &cost,
         vector<long long> adj[], long long &mini) {
  marked[u] = true;
  mini = min(mini, cost[u]);
  long long j;
  for (j = 0; j < adj[u].size(); j++) {
    if (!marked[adj[u][j]]) dfs(adj[u][j], marked, cost, adj, mini);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  t = 1;
  while (t--) {
    long long n;
    cin >> n;
    long long i;
    map<long long, long long> m;
    for (i = 0; i < n; i++) {
      long long f;
      cin >> f;
      m[f] = n - i;
    }
    long long k = INT_MIN;
    long long ans = -1;
    for (auto it : m) {
      if (it.second > k) {
        k = it.second;
        ans = it.first;
      }
    }
    cout << ans << endl;
  }
}
