#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  vector<long long int> x(n);
  vector<long long int> y(200001);
  for (long long int i = 0; i < n; i++) {
    x[i] = 0;
  }
  for (int i = 0; i < 200001; i++) {
    y[i] = 0;
  }
  for (long long int i = 0; i < n; i++) {
    cin >> x[i];
    y[x[i]] = i + 1;
  }
  long long int otvet = 1000000, miny = 1000000;
  for (long long int i = 0; i < 200001; i++) {
    if (y[i] < miny && y[i] != 0) {
      otvet = i;
      miny = y[i];
    }
  }
  cout << otvet;
  return 0;
}
