#include <bits/stdc++.h>
using namespace std;
int n, a[100010], mx1 = -100010, mx2 = -100010 - 10, ans = 1, cnt[100010];
int main() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) {
    if (a[i] > mx1) {
      mx2 = mx1;
      mx1 = a[i];
      cnt[a[i]]--;
    } else if (a[i] > mx2) {
      mx2 = a[i];
      cnt[mx1]++;
    }
  }
  for (int i = 1; i <= n; i++)
    if (cnt[i] > cnt[ans]) ans = i;
  cout << ans << endl;
  return 0;
}
