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>
static int _m1[100000], _idx1[100000], _m2[100000], _idx2[100000],
    _r_count[100000] = {};
static int solve(int N, int pi[static N]) {
  if (N == 1) return pi[0];
  _m1[0] = pi[0], _m2[0] = pi[0], _idx1[0] = 0, _idx2[0] = 0;
  if (pi[1] < pi[0]) {
    _m1[1] = pi[0], _m2[1] = pi[1], _idx1[1] = 0, _idx2[1] = 1;
  } else {
    _m1[1] = pi[1], _m2[1] = pi[0], _idx1[1] = 1, _idx2[1] = 0;
  }
  for (int i = 2; i < N; ++i) {
    if (pi[i] > _m1[i - 1]) {
      _m2[i] = _m1[i - 1], _idx2[i] = _idx1[i - 1];
      _m1[i] = pi[i], _idx1[i] = i;
    } else {
      _m1[i] = _m1[i - 1], _idx1[i] = _idx1[i - 1];
      if (pi[i] > _m2[i - 1]) {
        _m2[i] = pi[i], _idx2[i] = i;
      } else {
        _m2[i] = _m2[i - 1], _idx2[i] = _idx2[i - 1];
      }
    }
  }
  for (int i = 0; i < N; ++i)
    if (_idx1[i] != i) {
      ++_r_count[i];
      if (_idx2[i] == i) ++_r_count[_idx1[i]];
    }
  int maxr = _r_count[0], maxi = 0;
  for (int i = 1; i < N; ++i) {
    if (_r_count[i] > maxr || (_r_count[i] == maxr && pi[i] < pi[maxi]))
      maxr = _r_count[i], maxi = i;
  }
  return pi[maxi];
}
static int solve_bruteforce(int N, int pi[static N]) {
  int maxr = -1, maxi = -1;
  for (int i = 0; i < N; ++i) {
    const int p = pi[i];
    pi[i] = -1;
    int count = 0;
    for (int j = 1; j < N; ++j) {
      if (j == i) continue;
      bool rec = true;
      for (int k = 0; k < j && rec; ++k)
        if (pi[k] > pi[j]) rec = false;
      if (rec) ++count;
    }
    if (count > maxr) {
      maxr = count;
      maxi = i;
    } else if (count == maxr && pi[i] < pi[maxi]) {
      maxi = i;
    }
    pi[i] = p;
  }
  return pi[maxi];
}
static inline bool next_permutation(int n, int elem[static n]) {
  for (int k = n - 2; k >= 0; --k) {
    const int ak = elem[k], ak1 = elem[k + 1];
    if (ak >= ak1) continue;
    for (int l = n - 1, ln = k; l > ln; --l) {
      const int al = elem[l];
      if (al <= ak) continue;
      elem[l] = ak, elem[k] = al;
      for (int i = k + 1, j = n - 1; i < j; ++i, --j) {
        const int tmp = elem[i];
        elem[i] = elem[j];
        elem[j] = tmp;
      }
      return true;
    }
  }
  return false;
};
static int _pi[100000];
int main() {
  int N;
  scanf("%d\n", &N);
  for (int i = 0; i < N; ++i) scanf("%d ", &_pi[i]);
  printf("%d\n", solve(N, _pi));
  return 0;
}
