#include <bits/stdc++.h>
using namespace std;
int v[100001];
int main() {
  int n, x = 0, lar = 0, sec = 0, ans = 1;
  cin >> n;
  for (int i = 1; i <= n; i++) v[i] = 0;
  for (int i = 0; i < n; i++) {
    cin >> x;
    if (x > lar) {
      v[x] = -1;
      sec = lar;
      lar = x;
    } else if (x > sec) {
      v[lar]++;
      sec = x;
    }
  }
  for (int i = 1; i <= n; i++)
    if (v[ans] < v[i]) ans = i;
  cout << ans << "\n";
  return 0;
}
