#include <bits/stdc++.h>
using namespace std;
map<int, int> mp;
int main() {
  int n;
  cin >> n;
  vector<int> v;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (!mp[a]) v.push_back(a);
    mp[a] = i;
  }
  int ans = 0, mn = INT_MAX;
  for (int i = 0; i < v.size(); i++) {
    if (mp[v[i]] < mn) {
      mn = mp[v[i]];
      ans = v[i];
    }
  }
  cout << ans;
}
