#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 7;
int n;
int a[MAXN], r[MAXN], x[MAXN], vt[MAXN];
set<int> tset;
int main() {
  cin >> n;
  int tmax = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    vt[a[i]] = i;
    if (a[i] > tmax) {
      r[i] = 1;
      tmax = a[i];
    }
  }
  tset.insert(a[0]);
  x[0] -= r[0];
  for (int j = 1; j < n; j++) {
    tset.insert(a[j]);
    set<int>::iterator it = tset.end();
    it--;
    it--;
    set<int>::iterator it2 = tset.end();
    it2--;
    if (*it == a[j]) {
      x[vt[*it2]]++;
    }
    x[j] -= r[j];
  }
  int ans = a[0];
  tmax = x[0];
  for (int i = 0; i < n; i++) {
    if (x[i] > tmax) {
      tmax = x[i];
      ans = a[i];
    } else if (x[i] == tmax) {
      ans = min(ans, a[i]);
    }
  }
  cout << ans;
}
