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 org.omg.CORBA.DATA_CONVERSION;

import java.io.*;
import java.time.temporal.TemporalAmount;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Stream;

public class Solution {


    static MyScanner sc;
    private static PrintWriter out;
    static long M2 = 1_000_000_000L + 7;

    private static HashMap<Long, Long>[] mods;

    public static void main(String[] s) throws Exception {
        StringBuilder stringBuilder = new StringBuilder();
        if (stringBuilder.length() == 0) {
            sc = new MyScanner(System.in);
        } else {
            sc = new MyScanner(new BufferedReader(new StringReader(stringBuilder.toString())));
        }

        out = new PrintWriter(new OutputStreamWriter(System.out));

        initData();
        solve();
        out.flush();
    }

    private static void initData() {

    }

    private static void solve() throws IOException {
        int n = sc.nextInt();
        int[] data = sc.na(n);
        int max[] = new int[2];
        int[] tom = new int[n + 1];
        for (int i = 0; i < n; i++) {
            if (data[i] > max[1]) {
                max[0] = max[1];
                max[1] = data[i];
                continue;
            }
            if (data[i] > max[0]) {
                tom[max[1]]++;
                max[0] = data[i];
                continue;
            }
            tom[data[i]]++;

        }
        int r = 1;
        for (int k = 2; k <= n; k++) {
            if (tom[k] > tom[r]) {
                r = k;
            }
        }
        out.println(r);


    }


    private static boolean isset(long i, int k) {
        return (i & (1 << k)) > 0;
    }

    private static void solveT() throws IOException {
        int t = sc.nextInt();
        while (t-- > 0) {
            solve();
        }
    }


    private static final class STree {
        long[] val1;
        int[] from1;
        int[] to1;
        long[] sum1;

        public STree(int[] data) {
            this(data.length);
            int ss = val1.length / 2;
            for (int i = 0; i < data.length; i++) {
                val1[i + ss] = data[i];
            }

        }

        public STree(int c) {
            int size = Integer.highestOneBit(c);
            if (size != c) {
                size <<= 1;
            }
            int rs = size << 1;
            val1 = new long[rs];
            from1 = new int[rs];
            sum1 = new long[rs];
            to1 = new int[rs];

            Arrays.fill(from1, Integer.MAX_VALUE);
            for (int r = rs - 1; r > 1; r--) {
                if (r >= size) {
                    from1[r] = r - size;
                    to1[r] = r - size;
                }
                from1[r / 2] = Math.min(from1[r / 2], from1[r]);
                to1[r / 2] = Math.max(to1[r / 2], to1[r]);
            }
        }

        public void add(int from, int to, int val) {
            add(1, from, to, val);
        }

        private void add(int cur, int from, int to, int val) {
            if (cur >= val1.length) return;
            if (from <= from1[cur] && to1[cur] <= to) {
                val1[cur] += val;
                addToParent(cur, ((long) to1[cur] - from1[cur] + 1) * val);
                return;
            }
            if (from1[cur] > to || from > to1[cur]) {
                return;
            }
            add((cur << 1) + 1, from, to, val);
            add(cur << 1, from, to, val);
        }

        private void addToParent(int cur, long l) {
            while (cur > 1) {
                sum1[cur >>= 1] += l;
            }
        }

        public long sum(int from, int to) {
            return sum(1, from, to);
        }

        private long val(int vl) {
            return sum(vl, vl);
        }

        private long sum(int cur, int from, int to) {
            if (cur >= val1.length) return 0;
            if (from <= from1[cur] && to1[cur] <= to) {
                return val1[cur] * (to1[cur] - from1[cur] + 1) + sum1[cur];
            }
            if (from1[cur] > to || from > to1[cur]) {
                return 0;
            }
            int c1 = Math.max(from, from1[cur]);
            int c2 = Math.min(to, to1[cur]);
            return (c2 - c1 + 1) * val1[cur] + sum((cur << 1) + 1, from, to) + sum(cur << 1, from, to);
        }
    }


    private static long gcd(long l, long l1) {
        if (l > l1) return gcd(l1, l);
        if (l == 0) return l1;
        return gcd(l1 % l, l);
    }

    private static long pow(long a, long b, long m) {
        if (b == 0) return 1;
        if (b == 1) return a;
        long pp = pow(a, b / 2, m);
        pp *= pp;
        pp %= m;
        return (pp * (b % 2 == 0 ? 1 : a)) % m;
    }


    static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        MyScanner(BufferedReader br) {
            this.br = br;
        }

        public MyScanner(InputStream in) {
            this(new BufferedReader(new InputStreamReader(in)));
        }

        void findToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        String next() {
            findToken();
            return st.nextToken();
        }

        Integer[] nab(int n) {
            Integer[] k = new Integer[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.fi();
            }
            return k;
        }

        int[] na(int n) {
            int[] k = new int[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.fi();
            }
            return k;
        }

        long[] nl(int n) {
            long[] k = new long[n];
            for (int i = 0; i < n; i++) {
                k[i] = sc.nextLong();
            }
            return k;
        }

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

        int fi() {
            String t = next();
            int cur = 0;
            boolean n = t.charAt(0) == '-';
            for (int a = n ? 1 : 0; a < t.length(); a++) {
                cur = cur * 10 + t.charAt(a) - '0';
            }
            return n ? -cur : cur;
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }


}