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 + 10;
long long int rangeQuery(long long int segtree[], long long int qlow,
                         long long int qhigh, long long int low,
                         long long int high, long long int pos) {
  if (qlow > qhigh) return 0;
  if (qlow <= low && qhigh >= high) {
    return segtree[pos];
  }
  if (qlow > high || qhigh < low) {
    return 0;
  }
  long long int mid = (low + high) / 2;
  return rangeQuery(segtree, qlow, qhigh, low, mid, 2 * pos + 1) +
         rangeQuery(segtree, qlow, qhigh, mid + 1, high, 2 * pos + 2);
}
void update(long long int segtree[], long long int qlow, long long int qhigh,
            long long int low, long long int high, long long int val,
            long long int pos) {
  if (qlow <= low && qhigh >= high) {
    segtree[pos] = val;
    return;
  }
  if (qlow > high || qhigh < low) {
    return;
  }
  long long int mid = (low + high) / 2;
  update(segtree, qlow, qhigh, low, mid, val, 2 * pos + 1);
  update(segtree, qlow, qhigh, mid + 1, high, val, 2 * pos + 2);
  segtree[pos] = segtree[2 * pos + 1] + segtree[2 * pos + 2];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int n;
  cin >> n;
  long long int i, a[N + 10], ans[N + 10], seg[4 * N + 10], fre[N + 10];
  memset(ans, 0, sizeof(ans));
  memset(seg, 0, sizeof(seg));
  memset(fre, 0, sizeof(fre));
  for (i = 1; i <= n; i++) cin >> a[i];
  if (n == 1) {
    cout << "1"
         << "\n";
  } else {
    if (a[1] > a[2]) {
      fre[a[1] - 1]++;
      fre[a[2] - 1]++;
    }
    update(seg, a[1] - 1, a[1] - 1, 0, n - 1, 1, 0);
    update(seg, a[2] - 1, a[2] - 1, 0, n - 1, 1, 0);
    long long int maxi = max(a[1] - 1, a[2] - 1);
    for (i = 3; i <= n; i++) {
      long long int ele = a[i] - 1;
      long long int tmp = rangeQuery(seg, ele + 1, n - 1, 0, n - 1, 0);
      if (tmp == 1) fre[maxi]++;
      if (tmp > 1) fre[ele]++;
      maxi = max(maxi, ele);
      update(seg, ele, ele, 0, n - 1, 1, 0);
    }
    long long int flag = 0, res = 0;
    for (i = 0; i <= n - 1; i++) {
      if (fre[i] >= 2) {
        flag = 1;
      }
      if (fre[i] > fre[res]) res = i;
    }
    cout << res + 1 << "\n";
  }
  return 0;
}
