#include <bits/stdc++.h>
using namespace std;
int f[100005];
int main() {
  int n, a, nr = 1, max1 = 0, max2 = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a;
    if (a > max1) {
      max2 = max1;
      max1 = a;
      f[a]--;
    } else if (a > max2) {
      max2 = a;
      f[max1]++;
    }
  }
  for (int i = 2; i <= n; i++)
    if (f[i] > f[nr]) nr = i;
  cout << nr;
  return 0;
}
