#include <bits/stdc++.h>
using namespace std;
int main() {
  map<long long int, long long int> m, n;
  int a, b[300005], c, d, i, j, k = 0, l = 0;
  cin >> a;
  for (i = 0; i < a; i++) {
    cin >> b[i];
    m[b[i]]++;
    if (m[b[i]] == 1) l++;
  }
  for (i = a - 1; i >= 0; i--) {
    n[b[i]]++;
    if (n[b[i]] == 1) k++;
    if (l == k) {
      cout << b[i];
      return 0;
    }
  }
}
