#include <bits/stdc++.h>
using namespace std;
struct pairvar {
  int a;
  int b;
};
bool isPrime(long long x) {
  if (x == 1) {
    return false;
  }
  long long a = (long long)x;
  for (int i = 2; i <= (long long)sqrt((double)a); i++) {
    if (a % i == 0) {
      return false;
    }
  }
  return true;
}
int gcd(int a, int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
long long factorial(long long x) {
  long long sum = 1;
  for (long long i = 1; i <= x; i++) {
    sum *= i;
  }
  return sum;
}
int toint(string s) {
  int x = 0;
  int k = (int)pow(10, (double)s.length() - 1);
  for (int i = 0; i < (int)s.length(); i++) {
    x += (s[i] - '0') * k;
    k /= 10;
  }
  return x;
}
string tostr(int x) {
  if (x == 0) {
    return "0";
  }
  string s = "";
  bool f = x < 0;
  x = abs(x);
  while (x != 0) {
    s += (x % 10) + '0';
    x /= 10;
  }
  string t = "";
  if (f) {
    t = "-";
  }
  for (int i = s.length() - 1; i >= 0; i--) {
    t += s[i];
  }
  return t;
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
string tobin(int a) {
  string s;
  while (a != 0) {
    s += '0' + (a % 2);
    a /= 2;
  }
  string r = "";
  for (int i = s.length() - 1; i >= 0; i--) {
    r += s[i];
  }
  return r;
}
bool cmp(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first == b.first) {
    return a.second < b.second;
  }
  return a.first < b.first;
}
int cnt[2000005];
int main() {
  int n;
  cin >> n;
  set<int> w;
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    w.insert(x);
    cnt[x] = i;
  }
  int mn = 1000000000;
  int ans = 0;
  for (int i = 0; i < 200005; i++) {
    if (cnt[i] < mn && cnt[i] && w.find(i) != w.end()) {
      mn = cnt[i];
      ans = i;
    }
  }
  cout << ans;
  return 0;
}
