#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
int main() {
  vector<int> a(300000, INT_MAX);
  int n, mi = 3000000, res;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int idx;
    cin >> idx;
    a[idx] = i;
  }
  for (int i = 0; i < 300000; ++i) {
    if (mi > a[i]) {
      mi = a[i];
      res = i;
    }
  }
  cout << res << endl;
  return 0;
}
