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;
typedef struct data {
  long long q;
  long long r;
} data;
int getSum(int BITree[], int index) {
  int sum = 0;
  index = index + 1;
  while (index > 0) {
    sum += BITree[index];
    index -= index & (-index);
  }
  return sum;
}
void updateBIT(int BITree[], int n, int index, int val) {
  index = index + 1;
  while (index <= n) {
    BITree[index] += val;
    index += index & (-index);
  }
}
int *constructBITree(int n) {
  int *BITree = new int[n + 1];
  for (int i = 1; i <= n; i++) BITree[i] = 0;
  return BITree;
}
long long A[100005];
long long B[100005];
long long D[100005];
vector<long long> V;
set<long long> S;
set<long long> S1;
set<long long>::iterator it;
int main() {
  long long T = 0, N = 0, R = 0, i = 0, len = 0, end = 0, max = 0, x = 0, y = 0,
            z = 0, r = 0, a = 0, b = 0, c = 0, K = 0;
  scanf("%lld", &N);
  int *BITree = constructBITree(N);
  memset(A, 0, sizeof(A));
  memset(B, 0, sizeof(B));
  for (i = 0; i < N; i++) {
    scanf("%lld", &x);
    V.push_back(x);
    A[x] = i;
  }
  for (i = N; i > 0; i--) {
    it = S1.lower_bound(A[i]);
    if (S1.empty() || it == S1.begin()) {
      D[i] = 1;
      K++;
    }
    S1.insert(A[i]);
  }
  for (i = N; i > 0; i--) {
    x = A[i];
    y = getSum(BITree, x);
    if (y == 1) {
      it = S.lower_bound(x);
      it--;
      a = *it;
      B[V[a]]++;
    }
    updateBIT(BITree, N, x, 1);
    S.insert(x);
  }
  for (i = 1; i <= N; i++) {
    b = B[i];
    B[i] = B[i] + K - D[i];
    if (i == 1 || B[i] > max) {
      max = B[i];
      R = i;
    }
  }
  printf("%lld\n", R);
  return 0;
}
