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

/**
 * @author ramil.agger
 *
 */


public class Main {


    void solve() {
        int n = nextInt();
        int[] a = nextArray(n);
        int cnt[] = new int[100500];
        int ma = 0;
        int ma2 = 0;
        for (int i = 0; i < n; i++) {
            if(a[i] > ma) {
                ma2 = ma;
                ma = a[i];
                cnt[ma]--;
                i++;
                for (; i < n; i++) {
                    if(a[i] > ma2 && a[i] < ma) {
                        cnt[ma]++;
                        ma2 = a[i];
                    }else if(a[i] > ma) {
                        i--;
                        break;
                    }
                }
            }else if(a[i] > ma2) {
                ma2 = a[i];
            }

        }

        int max = 1;

        for (int j = 1; j <= ma; j++) {
            if(cnt[j] > cnt[max])
                max = j;
        }

        pw.println(max);
    }


    public static void main(String[] args) {
        new Main();
    }


    void run() throws IOException {
        start = System.currentTimeMillis();
        solve();
        if (!ONLINE_JUDGE)
            System.err.println(System.currentTimeMillis() - start + " ms");
        br.close();
        pw.close();
    }


    Main() {

        try {
            br = (ONLINE_JUDGE)
                    ? new BufferedReader(new InputStreamReader(System.in))
                    : new BufferedReader(new FileReader("input.txt"));
            pw = (ONLINE_JUDGE)
                    ? new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)))
                    : new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
            this.run();
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException();
        }

    }

    boolean hasNext() {
        if (st != null && st.hasMoreTokens()) return true;
        try {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
        } catch (Exception e) {
            return false;
        }
        return true;
    }

    String next() {
        if (hasNext())
            return st.nextToken();
        return null;
    }

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

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

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

    BigInteger nextBigInteger() {
        return new BigInteger(next());
    }

    String nextLine() {
        if(hasNext()) return st.nextToken("\n");
        else return null;
    }

    int[] nextArray(int n){
        int[] temp = new int[n];
        for (int i = 0; i < n; i++)
            temp[i] = nextInt();
        return temp;
    }

    long[] nextLArray(int n) {
        long[] temp = new long[n];
        for (int i = 0; i < n; i++)
            temp[i] = nextInt();
        return temp;
    }

    final static boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    long start;
    final BufferedReader br;
    final PrintWriter pw;
    StringTokenizer st;
}