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 main() {
  vector<int> v;
  int n, i, egor, j;
  cin >> n;
  int arr[n];
  int nobs[n];
  int k = 0;
  for (i = 0; i < n; i++) {
    cin >> arr[i];
    if (v.size() == 0) {
      v.push_back(i);
      egor = arr[i];
    } else {
      if (v.size() > 0 && arr[i] > egor) {
        egor = arr[i];
        v.push_back(i);
      } else {
        nobs[k] = arr[i];
        k++;
      }
    }
  }
  if (v.size() == n) {
    cout << 1;
    return 0;
  }
  for (i = k; i < n; i++) {
    nobs[i] = n + 1;
  }
  sort(nobs, nobs + n);
  if (v.size() == 0) {
    cout << 1;
    return 0;
  }
  int impakt[v.size()];
  for (i = 0; i < v.size(); i++) impakt[i] = -1;
  int local = 0;
  v.push_back(n - 1);
  for (i = 0; i < v.size() - 1; i++) {
    if (i > 0) local = arr[v[i - 1]];
    for (j = v[i] + 1; j < v[i + 1]; j++) {
      if (arr[j] > local) {
        impakt[i]++;
        local = arr[j];
      }
    }
  }
  v.pop_back();
  int maximum = -1;
  int ans = -1;
  for (i = 0; i < v.size(); i++) {
    if (impakt[i] > maximum) {
      maximum = impakt[i];
      ans = i;
    }
  }
  if (maximum <= 0) {
    cout << nobs[0];
    return 0;
  }
  vector<int> maximka;
  for (i = 0; i < v.size(); i++) {
    if (impakt[i] == maximum) maximka.push_back(i);
  }
  if (maximka.size() == 1) {
    cout << arr[v[maximka[0]]];
    return 0;
  } else {
    vector<int> tashim;
    for (i = 0; i < maximka.size(); i++) tashim.push_back(arr[v[maximka[i]]]);
    sort(tashim.begin(), tashim.end());
    cout << tashim[0];
    return 0;
  }
  return 0;
}
