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.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static final int MAX_N = 100010;
    private static final double eps = 1e-8;
    private static final int[] num = new int[MAX_N];
    private static final int[] tree = new int[MAX_N];

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

//        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//        try {
        int n = in.nextInt();
        int max = 0;
        for (int i = 1; i <= n; i++) {
            int t = in.nextInt();
            int a = query(t);
            max = Math.max(t, max);
            if (a == i - 1) {
                num[max]--;
            } else if (a == i - 2) {
                num[max]++;
            }
            add(t);
//            System.out.println();
//            System.out.print("num:  ");
//            printArray(num, 1, n);
//            System.out.print("tree: ");
//            printArray(tree, 1, n);
        }
        int res = -1;
        int ans = 1;
        for (int i = 1; i <= n; i++) {
            if (num[i] > res) {
                res = num[i];
                ans = i;
            }
        }
        System.out.println(ans);

//        }catch (IOException e){}
    }

    static int lowBit(int i) {
        return (-i) & i;
    }

    static void add(int i) {
        while (i < MAX_N) {
            tree[i]++;
            i += lowBit(i);
        }
    }

    static int query(int i) {
        int ret = 0;
        while (i > 0) {
            ret += tree[i];
            i -= lowBit(i);
        }
        return ret;
    }

    static void printArray(int[] arr, int fromIndex, int toIndex) {
        for (int i = fromIndex; i <= toIndex; i++) {
            System.out.print(arr[i]+"  ");
        }
        System.out.println();
    }
}
