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;
class segtree {
 private:
  long long dfs(long long a, long long b, long long k, long long l,
                long long r) {
    if (r <= a || b <= l) {
      return 1001000100010001000;
    }
    if (a <= l && r <= b) {
      return tree[k];
    }
    long long m = (l + r) / 2;
    return min(dfs(a, b, k * 2 + 1, l, m), dfs(a, b, k * 2 + 2, m, r));
  }

 public:
  long long size;
  vector<long long> tree;
  segtree(long long _size, long long _firstnum) {
    size = 1;
    while (size < _size) size *= 2;
    size <<= 1;
    tree = vector<long long>(size, 0);
    if (_firstnum) {
      for (long long i = 0; i < tree.size(); i++) tree[i] = _firstnum;
    }
  }
  segtree(long long _size) {
    size = 1;
    while (size < _size) size *= 2;
    size <<= 1;
    tree = vector<long long>(size, 0);
  }
  long long getMin(long long left, long long right) {
    return dfs(left, right, 0, 0, size / 2);
  }
  void update(long long pos, long long value) {
    pos += (size / 2 - 1);
    tree[pos] = value;
    while (pos) {
      pos = (pos - 1) / 2;
      tree[pos] = min(tree[pos * 2 + 1], tree[pos * 2 + 2]);
    }
  }
  long long get_allmin() { return tree[0]; }
};
template <class T>
struct BinaryIndexedTree {
  vector<T> data;
  BinaryIndexedTree(long long sz) { data.assign(++sz, 0); }
  T sum(long long k) {
    T ret = 0;
    for (++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }
  void add(long long k, T x) {
    for (++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  long long n;
  cin >> n;
  ;
  vector<long long> data(n);
  segtree seg(n);
  for (long long i = 0; i < n; i++) {
    cin >> data[i];
    seg.update(i, -data[i]);
  }
  vector<bool> record(n + 1, false);
  long long yui = 0;
  for (long long i = 0; i < n; i++) {
    record[data[i]] = data[i] > yui;
    yui = max(yui, data[i]);
  }
  vector<long long> cnt(n + 1, 0);
  BinaryIndexedTree<long long> funami(n + 1);
  for (long long i = 0; i < n; i++) {
    if (funami.sum(data[i]) == i - 1) {
      cnt[-seg.getMin(0, i)]++;
    }
    funami.add(data[i], 1);
  }
  long long ans = 0;
  for (long long i = 1; i < n + 1; i++) {
    if (cnt[ans] < cnt[i]) {
      ans = i;
    }
  }
  if (ans && cnt[ans] > 1) {
    cout << ans << endl;
    return 0;
  } else {
    for (long long i = 1; i < n + 1; i++) {
      if (!record[i]) {
        cout << i << endl;
        return 0;
      }
    }
  }
  cout << 1 << endl;
  return 0;
}
