#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int a[N], last[N];
int main() {
  memset(last, 0x3f, sizeof(last));
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
    last[a[i]] = i;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    if (last[a[i]] < last[ans]) {
      ans = a[i];
    }
  }
  printf("%d\n", ans);
  return 0;
}
