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;
using lli = long long int;
template <class T>
class bit {
 public:
  vector<T> dat;
  int n;
  bit(int n) : n(n) { dat.assign(n, 0); }
  bit(int n, T ini) : n(n) { dat.assign(n, ini); }
  T sum(int i) {
    int ret = 0;
    for (--i; i >= 0; i = (i & (i + 1)) - 1) ret += dat[i];
    return ret;
  }
  T sum(int i, int j) { return sum(j) - sum(i); }
  void add(int i, T x) {
    for (; i < n; i |= i + 1) dat[i] += x;
  }
};
template <class T>
class segtree {
 public:
  lli n;
  vector<T> dat;
  function<T(T, T)> func;
  T dummy;
  segtree<T>(lli _n, T ini, function<T(T, T)> f, T dummy)
      : func(f), dummy(dummy) {
    n = 1;
    while (n < _n) {
      n = n * 2;
    }
    dat.assign(2 * n - 1, ini);
  }
  void update(lli k, T a) {
    k += n - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = func(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  T query(int a, int b) { return query(a, b, 0, 0, n); }
  T query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return dummy;
    if (a <= l && r <= b)
      return dat[k];
    else {
      T vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
      T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
      return func(vl, vr);
    }
  }
  T get(int a) { return query(a, a + 1, 0, 0, n); }
};
int main() {
  int n;
  scanf("%d", &n);
  int first = 1e7;
  auto f = [](int a, int b) -> int { return min(a, b); };
  segtree<int> seg(n + 10, first, f, first);
  vector<int> a(n);
  vector<int> p(n);
  for (lli i = 0; i < (n); i++) {
    cin >> a[i];
    a[i]--;
    p[a[i]] = i;
  }
  for (lli i = 0; i < (n); i++) {
    seg.update(p[i], i);
  }
  bit<int> bi(n);
  int ans = 0;
  vector<int> cnt(n, 0);
  for (lli i = 0; i < (n); i++) {
    int sum = bi.sum(p[i]);
    seg.update(p[i], first);
    bi.add(p[i], 1);
    if (p[i] == sum) {
      cnt[i]--;
    } else if (p[i] == sum + 1) {
      ans = seg.query(0, p[i]);
      cnt[ans]++;
    }
  }
  ans = max_element(cnt.begin(), cnt.end()) - cnt.begin();
  cout << ans + 1 << endl;
}
