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 {

    static final long M = 1000000007;

    public static void main(String args[]) {

        FastReader io = new FastReader();    

        int n = io.nextInt();

        int[] p = new int[n];

        for(int i = 0;i < n; i++){
            p[i] = io.nextInt();
        }

        TreeSet<Integer> set = new TreeSet<>();

        int[] hash = new int[n + 1];
        int[] rec = new int[n + 1];

        int count = 0;

        for(int i = 0;i < n;i++){

            if(set.size() == 0 || set.higher(p[i]) == null){
                rec[p[i]] = 1;
                count++;
            }
            else if(set.higher(p[i]) == set.last()){
                hash[set.last()] ++;
            }
            set.add(p[i]);
        }
//        System.out.println(count);
//
//        for(int i = 1;i <= n;i++){
//            System.out.print(hash[i] + " ");
//        }
//        System.out.println();

        int ret = 1,maxr = count;

        for(int i = n;i >= 1;i--){
            if(count + hash[i] - rec[i] >= maxr){
                ret = i;
                maxr = count + hash[i]-rec[i];
            }
        }

        System.out.println(ret);

    }
}

class Solver{
    static final long MAX = 10000000000L;

    public void solve(int n,int m) {
        int i = (n - 2)*2 + 1;
        for(;i <= 1000000000;i++){
            boolean flag = true;
            if( i == 1)continue;
            for(int j = 2;j*j <= i;j++){
                if(j%i == 0){
                    flag = false;
                    break;
                }

            }
            if(flag)break;
        }

        ArrayList<Pair> g[] = new ArrayList[n + 1];

        for(int j = 0;j <= n;j++){
            g[j] = new ArrayList<>();
        }

        for(int j = 2;j <= n;j++){
            if(j == 2) {
                g[1].add(new Pair(j,i - (n -2)*2));
                continue;
            }
            g[1].add(new Pair(j,2));

        }
        int j = n - 1;
        for(int k =2;k <= n && j < m;k++){
            int e = 2;

            while(j < m && e <= n){
                if(e == k){
                    e++;
                    continue;
                }

                g[k].add(new Pair(e,1));
                e++;
                j++;
            }
        }

        System.out.println(2 + " "+i);
        for(int k = 1;k <= n;k++){
            for(int p = 0;p < g[k].size();p++){
                System.out.println(k + " " + g[k].get(p).u + " " +g[k].get(p).v);
            }
        }

    }
}

class Pair{
    int u,v;
    Pair(int u,int v){
        this.u = u;
        this.v = v;
    }
}

class CharStack {
    final StringBuilder sb = new StringBuilder();

    public void push(char ch) {
        sb.append(ch);
    }

    public char pop() {
        int last = sb.length() -1;
        char ch= sb.charAt(last);
        sb.setLength(last);
        return ch;
    }

    public int size() {
        return sb.length();
    }

    public boolean empty(){
        return (sb.length() == 0);
    }

    public char peek(){
        return sb.charAt(sb.length() - 1);
    }
    public  void  show(){
        System.out.println(sb);
    }
    public char[] get(){
        return  sb.toString().toCharArray();
    }
}

class DSU{
    int parent[] = new int[26];

    DSU(){
        for(int i = 0;i < 26; i++){
            parent[i] = -1;
        }
    }

    int getParent(int u){
        if(this.parent[u] == -1)
            return u;

        parent[u] = getParent(parent[u]);

        return parent[u];
    }

    void makeParent(int u,int v){
        int pu = getParent(u);
        int pv = getParent(v);

        parent[pu] = pv;
    }


}

class Util{
    static  final  long M = 998244353;
    static long modexp(long n,long m){
        if(m==0)
            return 1;
        else if(m==1)
            return n;
        else{
            long p = modexp(n,m/2);

            if(m%2==1)
                return (((p*p)%M)*n)%M;
            else
                return (p*p)%M;
        }
    }

    static  long exp(long n,long m){
        if(m == 0)
            return 1;
        if(m == 1)
            return n;

        long p = exp(n,m/2);

        if(m%2 == 1)
            return p*p*n;
        else
            return p*p;
    }

    static long gcd(long a,long b){
        if(a==0)
            return b;

        return gcd(b%a,a);
    }

    static long inv(long n){
        return modexp(n,M-2);
    }

    static long lcm(long a,long b){
        return a*b/gcd(a,b);
    }
    static long factorial(long fact[],long n){
        fact[0]=1;
        fact[1]=1;

        long prod = 1;

        for(int i = 2;i <= n;i++){
            prod = (prod*i)%M;

            fact[i] = prod;
        }

        return prod;
    }

    static boolean isPrime(long n){
        for(int i = 2;i*i <= n;i++){
            if(n%i == 0)
                return false;
        }
        return true;
    }
}

class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
        br = new BufferedReader(new
                InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            }
            catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

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

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

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

    String nextLine() {
        String str = "";
        try {
            str = br.readLine();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return str;
    }
}