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

public class Solution {

    public static void solve(InputReader in, PrintWriter out, DebugWriter debug) throws IOException {
        int n = in.nextInt();
        int[] p = in.nextIntArray(n);

        if (n == 1){
            out.println(p[0]);
            return;
        }

        int max = 0;
        int predMax = 0;

        int countRec = 0; //Кол-во, если ничего не удалять
        int[] dp = new int[n]; //Кол-во рекордов, если я удалю этот элемент ([значение-1], а не индекс)
        boolean[] inMaxSq = new boolean[n];

        for (int i=0; i<n; i++){
            if (p[i] > max){
                predMax = max;
                max = p[i];

                countRec++;
                inMaxSq[p[i]-1] = true;
            }

            if (p[i] < max && p[i] > predMax){
                predMax = p[i];
                dp[max-1]++;
            }
        }

        for (int i = 1; i <= n; i++) {
            if (inMaxSq[i-1]){
                dp[i-1] = dp[i-1]+countRec-1;
            } else {
                dp[i-1] = countRec;
            }
        }

        int ansCount = 0;
        int val = -1;
        for (int i=n-1; i >= 0; i--){
            if (dp[i] >= ansCount){
                ansCount = dp[i];
                val = i+1;
            }
        }

        if (val == -1) throw new RuntimeException();

        for (int i = 0; i < n; i++) {
            debug.print(dp[i] + ",");
        }
        debug.println("");

        debug.println(ansCount);
        debug.println(countRec);
        out.println(val);
    }

    public static final String NAME = "";

    public static void main(String[] args) throws IOException{
        InputReader in;
        PrintWriter out;
        DebugWriter debug;

        if (args.length > 0 && args[0].equals("file")) {
            in = new InputReader(new BufferedReader(new FileReader("input.txt")));
            out = new PrintWriter(new FileWriter("output.txt"));
            debug = new DebugWriter(true);

            int sampleNumber = 1;
            do {
                String nextSample = "Sample #" + sampleNumber++ + ": ";
                out.println(nextSample);
                debug.println(nextSample);

                solve(in, out, debug);

                out.println("");
                debug.println("");
            } while (in.reader.readLine() != null);
        } else {
            if (NAME.length() > 0) {
                in = new InputReader(new BufferedReader(new FileReader(NAME + ".in")));
                out = new PrintWriter(new FileWriter(NAME + ".out"));
            } else {
                in = new InputReader(new BufferedReader(new InputStreamReader(System.in)));
                out = new PrintWriter(new OutputStreamWriter(System.out));
            }

            debug = new DebugWriter(false);
            solve(in, out, debug);
        }

        in.reader.close();
        out.close();
    }

    public static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(BufferedReader reader) {
            this.reader = reader;
            tokenizer = null;
        }

        public String next() throws IOException{
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }

            return tokenizer.nextToken();
        }

        public int nextInt() throws IOException{
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) throws IOException{
            int[] array = new int[n];
            for (int i=0; i<n; i++){
                array[i] = nextInt();
            }

            return array;
        }
    }

    public static class DebugWriter {
        public boolean enable;

        public DebugWriter(boolean enable){
            this.enable = enable;
        }

        public void print(Object o){
            if (enable) System.out.print(o);
        }

        public void println(Object o){
            if (enable) System.out.println(o);
        }
    }

}