You are given a permutation p of length n. Remove one element from permutation to make the number of records the maximum possible.

We remind that in a sequence of numbers a1, a2, ..., ak the element ai is a record if for every integer j (1 ≤ j < i) the following holds: aj < ai. 

Input

The first line contains the only integer n (1 ≤ n ≤ 105) — the length of the permutation.

The second line contains n integers p1, p2, ..., pn (1 ≤ pi ≤ n) — the permutation. All the integers are distinct.

Output

Print the only integer — the element that should be removed to make the number of records the maximum possible. If there are multiple such elements, print the smallest one.

Examples

Input

1
1


Output

1


Input

5
5 1 2 3 4


Output

5

Note

In the first example the only element can be removed.
#include <bits/stdc++.h>
using namespace std;
int toNumber(string s) {
  int Number;
  if (!(istringstream(s) >> Number)) Number = 0;
  return Number;
}
string toString(int number) {
  ostringstream ostr;
  ostr << number;
  return ostr.str();
}
long long ele(long long a, long long b) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    return ele((a * a), b / 2);
  } else {
    return a * ele((a * a), b / 2);
  }
}
long long mcd(long long a, long long b) {
  if (a == 0) return b;
  return mcd(b % a, a);
}
double d_abs(long a, long b) {
  if (a > b) {
    return a - b;
  }
  return b - a;
}
void solve() {
  int n;
  cin >> n;
  vector<int> perm(n);
  for (long long i = 0; i < (long long)(n); i++) cin >> perm[i];
  if (n == 1 || n == 2) {
    cout << 1 << endl;
    return;
  }
  int masGrande, segundo;
  vector<int> genera(n + 1, 0);
  vector<bool> seguro(n + 1, false);
  seguro[perm[0]] = true;
  if (perm[0] > perm[1]) {
    masGrande = perm[0];
    segundo = perm[1];
    genera[perm[0]]++;
  } else {
    seguro[perm[1]] = true;
    masGrande = perm[1];
    segundo = perm[0];
  }
  for (long long i = (2); i < (long long)(n); i++) {
    if (perm[i] > masGrande) {
      segundo = masGrande;
      seguro[perm[i]] = true;
      masGrande = perm[i];
    } else if (perm[i] > segundo) {
      genera[masGrande]++;
      segundo = perm[i];
    }
  }
  int maxi = -1;
  int saco = 1;
  for (long long i = (1); i < (long long)(n + 1); i++) {
    if (seguro[i]) {
      genera[i]--;
    }
    if (genera[i] > maxi) {
      maxi = genera[i];
      saco = i;
    }
  }
  cout << saco << endl;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int T;
  T = 1;
  while (T--) {
    solve();
  }
}
