#include <bits/stdc++.h>
using namespace std;
int n, a[100010], cnt[100010];
int main() {
  int max1 = 0, max2 = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 1; i <= n; i++) {
    if (a[i] > max1) {
      max2 = max1;
      max1 = a[i];
      cnt[a[i]]--;
    } else {
      if (a[i] > max2) {
        cnt[max1]++;
        max2 = a[i];
      }
    }
  }
  int ans, max3 = -100000;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] > max3) {
      max3 = cnt[i];
      ans = i;
    }
  }
  printf("%d\n", ans);
}
