#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, ans, bigmax = INT_MIN, smallmax = INT_MIN;
int a[N], change[N];
bool mark[N];
void read_input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
}
void solve() {
  for (int i = 0; i < n; i++) {
    if (a[i] > bigmax) {
      change[a[i]] = -1;
      smallmax = bigmax;
      bigmax = a[i];
    } else if (a[i] > smallmax) {
      change[bigmax]++;
      smallmax = a[i];
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  read_input();
  solve();
  change[0] = -1;
  for (int i = n; i > 0; i--) {
    if (change[i] >= change[ans]) ans = i;
  }
  cout << ans;
  return 0;
}
