#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int a[100005];
int main() {
  int n, i, x, ans = 1, maxx = -1e9, maxxx = -1e9;
  cin >> n;
  for (i = 0; i < n; i++) {
    scanf("%d", &x);
    if (x > maxxx)
      maxx = maxxx, maxxx = x, a[x] = -1;
    else if (x > maxx)
      ++a[maxxx], maxx = x;
  }
  for (i = 1; i <= n; i++)
    if (a[i] > a[ans]) ans = i;
  cout << ans << endl;
  return 0;
}
