#include <bits/stdc++.h>
using namespace std;
int f_big, s_big, x, n;
int cnt[100010];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &x);
    if (x > f_big) {
      s_big = f_big;
      f_big = x;
      cnt[f_big] = -1;
    } else if (x > s_big) {
      s_big = x;
      cnt[f_big]++;
    }
  }
  int idx = 1;
  for (int i = 2; i <= n; ++i) {
    if (cnt[i] > cnt[idx]) idx = i;
  }
  printf("%d\n", idx);
  return 0;
}
