#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, ans = 1, first = 0, sec = 0;
  cin >> n;
  map<int, int> mp;
  int a;
  for (int i = 0; i < n; i++) {
    cin >> a;
    if (a > first) {
      sec = first;
      first = a;
      mp[first] = 1;
    } else if (a > sec) {
      mp[first]--;
      sec = a;
    }
  }
  for (int i = 1; i <= n; i++) {
    if (mp[ans] > mp[i]) ans = i;
  }
  cout << ans << endl;
}
