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>
#pragma GCC optimize("omit-frame-pointer")
#pragma GCC optimize("unroll-loops")
using namespace std;
string itosm(long long x) {
  if (x == 0) return "0";
  string ans = "";
  while (x > 0) {
    ans += ((x % 10) + '0');
    x /= 10;
  }
  reverse(ans.begin(), ans.end());
  return ans;
}
long long stoim(string str) {
  long long ans = 0;
  long long k = 1;
  for (int i = str.length() - 1; i >= 0; i--) {
    ans += (str[i] - '0') * k;
    k *= 10;
  }
  return ans;
}
const long long infll = 1e18 + 3;
const int inf = 1009000999;
const double eps = 1e-7;
const int maxn = 1e6 + 77;
const int baseint = 1000200013;
const long long basell = 1e18 + 3;
const long double PI = acos(-1.0);
const long long mod = 1e9 + 7;
int a[maxn];
pair<int, int> t[maxn];
int ans[maxn];
pair<int, int> foo(pair<int, int> a, pair<int, int> b) {
  if (a.first == 0)
    return b;
  else if (b.first == 0)
    return a;
  return {a.first + b.first, -1};
}
pair<int, int> getSum(int v, int tl, int tr, int l, int r) {
  if (l > r) return {0, 0};
  if (tl == l && tr == r) return t[v];
  int c = (tl + tr) / 2;
  return foo(getSum(v * 2, tl, c, l, min(c, r)),
             getSum(v * 2 + 1, c + 1, tr, max(c + 1, l), r));
}
void update(int v, int l, int r, int pos) {
  if (l == r) {
    t[v] = {1, pos};
    return;
  }
  int c = (l + r) / 2;
  if (pos <= c)
    update(v * 2, l, c, pos);
  else
    update(v * 2 + 1, c + 1, r, pos);
  t[v] = foo(t[v * 2], t[v * 2 + 1]);
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) {
    if (getSum(1, 0, n, a[i], n).first == 1)
      ans[getSum(1, 0, n, a[i], n).second]++;
    else if (getSum(1, 0, n, a[i], n).first == 0)
      ans[a[i]]--;
    update(1, 0, n, a[i]);
  }
  int mx = -1;
  for (int i = 1; i <= n; i++)
    if (mx == -1 || ans[mx] < ans[i]) mx = i;
  cout << mx;
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(0);
  ;
  cin.tie(0);
  solve();
  return 0;
}
