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.
import java.util.*;

public class C {
    static int[] numRecords;
    static int[] maxes;

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int[] nums = new int[n];
        removeToInc = new int[n + 1];
        for (int i = 0; i < n; i++) {
            nums[i] = scan.nextInt();
        }
        if (nums.length == 2) {
            System.out.println(Math.min(nums[0], nums[1]));
            return;
        } else if (nums.length == 1) {
            System.out.println(nums[0]);
            return;
        }

        calc2(nums);
        int maxAdded = -999999999;
        int num = Integer.MAX_VALUE;
        for (int i = 1; i <= n; i++) {
            if (removeToInc[i] > maxAdded) {
                maxAdded = removeToInc[i];
                num = i;
            } else if (removeToInc[i] == maxAdded) {
                if (i < num) {
                    num = i;
                }
            }
        }

        System.out.println(num);
    }

    static void calcNumRecord(int[] nums) {
        int maxSoFar = 0;
        int seen = 0;
        for (int i = 0; i < nums.length; i++) {
            
            if (nums[i] > maxSoFar) {
                seen++;
                numRecords[i] = seen;
            }
            maxSoFar = Math.max(maxSoFar, nums[i]);
            maxes[i] = maxSoFar;
        }
    }

    static int[] removeToInc;

    static void calc2(int[] nums) {
        PriorityQueue<Integer> Q = new PriorityQueue<>((a, b) -> b - a);
        Q.add(nums[0]);
        Q.add(nums[1]);
        removeToInc[nums[0]]--;
        if (nums[1] > nums[0]) {
            removeToInc[nums[1]]--;
        } else {
            removeToInc[nums[0]]++;
        }
        for (int i = 2; i < nums.length; i++) {
            int max = Q.poll();
            int secondMax = Q.peek();
            Q.add(max);
            if (nums[i] > max) {
                removeToInc[nums[i]]--;
            }
            if (nums[i] < max && nums[i] > secondMax) {
                removeToInc[max]++;
            }
            Q.add(nums[i]);
        }
    }
}