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;
template <class T>
int size(const T &x) {
  return x.size();
}
const int INF = ~(1 << 31);
const double EPS = 1e-9;
const double pi = acos(-1);
template <class T>
T smod(T a, T b) {
  return (a % b + b) % b;
}
int brute(vector<int> &perm) {
  int best = -1, bestval = -1;
  for (__typeof(0) i = (0); i < (size(perm)); ++i) {
    int mx = -1;
    int cnt = 0;
    for (__typeof(0) j = (0); j < (size(perm)); ++j) {
      if (i == j) continue;
      if (perm[j] > mx) {
        cnt++;
        mx = perm[j];
      }
    }
    if (cnt > best) {
      bestval = perm[i];
      best = cnt;
    } else if (cnt == best && perm[i] < bestval) {
      bestval = perm[i];
    }
  }
  return bestval;
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> perm(n);
  for (__typeof(0) i = (0); i < (n); ++i) {
    scanf("%d", &perm[i]);
    perm[i]--;
  }
  vector<int> big(n), fails;
  int firsthigh = -1, secondhigh = -1;
  for (__typeof(0) i = (0); i < (n); ++i) {
    if (firsthigh > perm[i] && secondhigh > perm[i]) {
      fails.push_back(perm[i]);
    }
    if (firsthigh > perm[i] && perm[i] > secondhigh) {
      fails.push_back(perm[i]);
      big[firsthigh]++;
    }
    if (perm[i] > firsthigh) {
      secondhigh = firsthigh;
      firsthigh = perm[i];
    } else if (perm[i] > secondhigh) {
      secondhigh = perm[i];
    }
  }
  int mx = 0, mxel = -1;
  for (__typeof(0) i = (0); i < (n); ++i) {
    if (big[i] > mx) {
      mxel = i;
      mx = big[i];
    }
  }
  if (mx <= 1 && size(fails)) {
    sort(fails.begin(), fails.end());
    mxel = fails[0];
  }
  if (mxel < 0) mxel = 0;
  cout << mxel + 1 << endl;
}
