#include <bits/stdc++.h>
using namespace std;
int cnt[100010];
int main() {
  int n;
  cin >> n;
  memset(cnt, 0, sizeof(cnt));
  int maxx = 0, max2x = 0;
  for (int i = 0; i < n; i++) {
    int x;
    scanf("%d", &x);
    if (x > maxx) {
      max2x = maxx;
      maxx = x;
      cnt[x]--;
    } else if (x > max2x) {
      max2x = x;
      cnt[maxx]++;
    }
  }
  int maxa = -0x3f3f3f3f, ans = 0;
  for (int i = 1; i <= n; i++) {
    if (cnt[i] > maxa) {
      maxa = cnt[i];
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}
