#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void chkmax(T &x, T y) {
  if (x < y) x = y;
}
template <class T>
inline void chkmin(T &x, T y) {
  if (x > y) x = y;
}
int n, p, ans, fimax, semax, id, tmp, cur, mini = 100100;
int main() {
  scanf("%d", &n);
  ans = cur = -100100;
  for (int i = 0; i < n; i++) {
    scanf("%d", &p);
    if (p > fimax) {
      semax = fimax, fimax = p;
      if (cur > ans) ans = cur, id = tmp;
      cur = -1, tmp = p;
    } else {
      mini = min(mini, p);
      if (p > semax) cur++, semax = p;
    }
  }
  if (cur > ans) ans = cur, id = tmp;
  if (ans <= 0 && mini < 100100) id = mini;
  printf("%d", id);
  return 0;
}
