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 long long int MOD = 1000000007;
long long int modpow(long long int a, long long int b, long long int mod) {
  long long int res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    res %= mod;
    a = a * a;
    a %= mod;
  }
  return res;
}
long long int p(long long int a, long long int b) {
  long long int res = 1;
  for (; b; b >>= 1) {
    if (b & 1) res = res * a;
    a = a * a;
  }
  return res;
}
void testcases() {
  long long int n;
  cin >> n;
  vector<long long int> a(n);
  for (long long int i = (long long int)0; i < (long long int)n; ++i)
    cin >> a[i];
  vector<long long int> b(n);
  set<long long int> meme;
  for (long long int i = (long long int)0; i < (long long int)n; ++i) {
    auto itr = meme.lower_bound(a[i]);
    if (!meme.empty() && itr == prev(meme.end())) {
      b[*itr - 1]++;
    }
    meme.insert(a[i]);
  }
  long long int maxx = -1;
  for (long long int i = (long long int)0; i < (long long int)n; ++i) {
    if (a[i] > maxx) {
      b[a[i] - 1]--;
    }
    maxx = ((maxx > a[i]) ? maxx : a[i]);
  }
  maxx = -1e15;
  long long int ans = 0;
  for (long long int i = (long long int)0; i < (long long int)n; ++i) {
    if (maxx < b[i]) {
      maxx = b[i];
      ans = i + 1;
    }
  }
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int t;
  t = 1;
  while (t--) testcases();
}
