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;
inline void file() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  if (0) {
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
  }
}
const int PX[8] = {1, 0, -1, 0, 1, 1, -1, -1},
          PY[8] = {0, 1, 0, -1, -1, 1, 1, -1}, N = 1e5 + 10, INF = 1e9,
          MOD = 1e9 + 7;
const long long INFL = 1e18, MODL = 1e9 + 7;
const long double EPS = 1e-9;
inline int rnd(int l = 0, int r = INF) {
  unsigned ans = rand();
  ans = (ans << 8) ^ rand();
  ans = (ans << 8) ^ rand();
  ans = (ans << 8) ^ rand();
  ans %= r - l + 1;
  return int(ans + l);
}
int n, sz, x, MIN_L, MAX_R;
pair<int, int> t[4 * N];
int sum[N], v[N];
int get(int p) {
  int v, l, r, mid, cnt;
  v = 1;
  l = 1;
  r = sz;
  cnt = 0;
  while (1) {
    if (t[v].first + !!cnt > 1) return -1;
    if (t[v].first) cnt = t[v].second;
    if (l == r) return cnt;
    mid = (l + r) / 2;
    if (p > mid) {
      l = mid + 1;
      v = v * 2 + 1;
    } else {
      r = mid;
      v = v * 2;
    }
  }
}
void add_seg(int v, int l, int r, int x) {
  if (l >= MIN_L && r <= MAX_R) {
    t[v].second = x;
    t[v].first++;
    return;
  }
  if (r < MIN_L || l > MAX_R) return;
  int mid = (l + r) / 2;
  add_seg(v * 2, l, mid, x);
  add_seg(v * 2 + 1, mid + 1, r, x);
}
inline int solve() {
  int res = 0;
  int ans = 1;
  for (int i = 1; i <= n; ++i) {
    int now, mx;
    now = mx = 0;
    for (int j = 1; j < i; ++j)
      if (v[j] > mx) {
        mx = v[j];
        ++now;
      }
    for (int j = i + 1; j <= n; ++j)
      if (v[j] > mx) {
        mx = v[j];
        ++now;
      }
    if (now == res) {
      res = now;
      ans = min(ans, v[i]);
    }
    if (now > res) {
      res = now;
      ans = v[i];
    }
  }
  return ans;
}
int main() {
  file();
  cin >> n;
  for (sz = 1; sz < n; sz *= 2)
    ;
  for (int i = 1; i <= n; ++i) {
    cin >> x;
    v[i] = x;
    int s = get(x);
    if (s > 0) ++sum[s];
    if (s == 0) --sum[x];
    MIN_L = 1;
    MAX_R = x;
    add_seg(1, 1, sz, x);
  }
  x = 1;
  for (int i = 1; i <= n; ++i)
    if (sum[i] > sum[x]) x = i;
  cout << x;
}
