#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  vector<int> tmp;
  for (int i = 0; i < 1000000; i++) v.push_back(0);
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    tmp.push_back(x);
    v[x] = i;
  }
  int mn = INT_MAX;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (v[tmp[i]] <= mn) {
      mn = v[tmp[i]];
      ans = tmp[i];
    }
  }
  cout << ans;
}
