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;
long long max(long long a, long long b) {
  if (a > b) return a;
  return b;
}
long long min(long long a, long long b) { return a + b - max(a, b); }
long long mod(long long a, long long b) {
  if (a > b)
    return a - b;
  else
    return b - a;
}
long long power(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  map<long long, long long> m1;
  set<long long> s1;
  long long n;
  cin >> n;
  long long ctr[n + 5];
  memset(ctr, 0, sizeof(ctr));
  long long x;
  long long arr[n + 5];
  for (long long i = 1; i <= n; i++) {
    cin >> arr[i];
    m1[arr[i]] = i;
  }
  long long isal[n + 5];
  memset(isal, 0, sizeof(isal));
  long long curmax = 0;
  for (long long i = 1; i <= n; i++) {
    s1.insert(arr[i]);
    if (arr[i] > curmax) {
      curmax = arr[i];
      isal[arr[i]] = 1;
      continue;
    } else {
      s1.erase(curmax);
      if (s1.upper_bound(arr[i]) == s1.end()) {
        ctr[curmax]++;
      }
      s1.insert(curmax);
    }
  }
  long long num = 1, cou = -1;
  for (long long i = 1; i <= n; i++) {
    if (ctr[i] > cou && (ctr[i] > isal[i] || isal[i] == 0)) {
      cou = ctr[i];
      num = i;
    }
  }
  if (m1[num] == 1 && cou == 1) {
    cout << 1;
    return 0;
  }
  cout << num;
}
