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;
const long long int N = 1e5 + 5, MOD = 1e9 + 7;
long long int BIT[N], n, a[N], vec[N];
set<long long int> st, st1;
void update(int x, long long int val) {
  for (; x <= n; x += (x & (-x))) {
    BIT[x] += val;
  }
}
long long int query(int x) {
  long long int sum = 0;
  for (; x >= 1; x = x - (x & (-x))) {
    sum += BIT[x];
  }
  return sum;
}
void brute() {
  long long int tmp = 0;
  for (long long int i = 1; i < n; i++) {
    int f = 1;
    for (long long int j = i - 1; j >= 0; j--) {
      if (a[j] > a[i]) {
        f = 0;
        break;
      }
    }
    if (f) {
      tmp++;
      cout << a[i] << endl;
    }
  }
  cout << endl << tmp << endl;
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  int f = 0;
  long long int mxx = -1;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (a[i] < mxx) f = 1;
    mxx = a[i];
  }
  if (!f) {
    cout << "1\n" << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    long long int sm = query(a[i] - 1);
    if (sm == i && i) {
      st1.insert(a[i]);
    }
    if (i == 0 || i == 1) {
      st.insert(a[i]);
      update(a[i], 1);
      continue;
    }
    st.insert(a[i]);
    update(a[i], 1);
    if (sm == i - 1) {
      set<long long int>::iterator itr = st.upper_bound(a[i]);
      vec[*itr]++;
    }
  }
  long long int mx = -1e18, ans = -1, pl = (int)st1.size();
  for (long long int i = 0; i < N; i++) {
    if (!vec[i]) continue;
    vec[i] += pl;
    if (st1.find(i) != st1.end()) vec[i]--;
    if (mx < vec[i]) {
      mx = vec[i];
      ans = i;
    }
  }
  if (ans == -1 || mx == pl) {
    ans = 1;
    if (a[0] == 1 && n > 2) ans = 2;
  }
  cout << ans << endl;
  return 0;
}
