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;
const int MAXN = 1e5 + 6.66;
int BIT[MAXN];
int arr[MAXN];
int dp[MAXN];
bool is[MAXN];
void add(int x, int val) {
  while (x < MAXN) BIT[x] += val, x += x & -x;
}
int get(int x) {
  int ans = 0;
  while (x) ans += BIT[x], x ^= x & -x;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin >> n;
  set<pair<int, int> > s;
  for (int i = 1; i <= n; i++) cin >> arr[i];
  for (int i = 1; i <= n; i++) {
    int w = get(n - arr[i] + 1);
    if (!w) is[i] = 1;
    if (w == 1) {
      dp[s.begin()->second]++;
    }
    s.insert(make_pair(-arr[i], i));
    add(n - arr[i] + 1, 1);
  }
  pair<int, int> mx = make_pair(-1, -1000000);
  for (int i = 1; i <= n; i++) {
    mx = max(mx, make_pair(dp[i] - is[i], -arr[i]));
  }
  if (mx.first >= 0)
    cout << -mx.second << endl;
  else {
    for (int i = 1; i <= n; i++) {
      if (!is[i]) {
        cout << i << endl;
        return 0;
      }
    }
    cout << 1 << endl;
  }
  return 0;
}
