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;
void solve() {
  long long n;
  cin >> n;
  vector<long long int> a(n), b(n + 1, 0), c(n + 1, 0);
  for (auto &it : a) cin >> it;
  set<long long> second;
  for (long long i = 0; i < n; i++) {
    if (((long long int)(second).size())) {
      auto it = second.upper_bound(a[i]);
      if (it != second.end()) {
        auto jt = it;
        jt++;
        if (jt == second.end()) b[(*it)]++;
      } else
        c[a[i]] = 1;
    } else
      c[a[i]] = 1;
    second.insert(a[i]);
  }
  for (auto &it : b)
    if (!it) it = 1;
  long long mx = 1;
  for (auto it : b) mx = max(mx, it);
  vector<long long int> ans;
  for (long long i = 1; i < n + 1; i++)
    if (mx == b[i]) ans.push_back(i);
  for (auto it : ans) {
    if (c[it] == 0) {
      cout << it;
      return;
    }
  }
  cout << ans[0];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.precision(20);
  long long t = 1;
  while (t--) {
    solve();
    cout << "\n";
  }
  cin.get();
  return 0;
}
