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.*;
public class Main {
    public static void main(String args[])
    {
        FastReader input=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        int T=1;
        while(T-->0)
        {
            int n=input.nextInt();
            int a[]=new int[n];
            for(int i=0;i<n;i++)
            {
                a[i]=input.nextInt();
            }
            int p=a[0];
            ArrayList<Integer> list=new ArrayList<>();
            list.add(0);
            for(int i=1;i<n;i++)
            {
                if(a[i]>p)
                {
                    p=a[i];
                    list.add(i);
                }
            }
            list.add(n);
            int sum=list.size()-2;
            int index=-1;
            int max=Integer.MIN_VALUE;
            for(int i=1;i<list.size();i++)
            {
                int x=list.get(i-1)+1;
                int y=list.get(i)-1;
                if(i==1)
                {
                    p=0;
                }
                else
                {
                    p=a[list.get(i-2)];
                }
                int count=0;
                for(int j=x;j<=y;j++)
                {
                    if(a[j]>p)
                    {
                        if(!(x==1 && j==x))
                        {
                            count++;
                        }
                        p=a[j];
                    }
                }
                if(x-1!=0)
                {
                    count--;
                }
                else
                {
                    if(y+1==1)
                    {
                        count--;
                    }
                }
                if(count>max)
                {
                    max=count;
                    index=a[x-1];
                }
            }
            if(max==0)
            {
                if(index==1)
                {
                    out.println(index);
                }
                else
                {
                    if(a[0]==1)
                    {
                        if(sum==0)
                        {
                            out.println(1);
                        }
                        else
                        {
                            out.println(Math.min(index,2));
                        }
                    }
                    else
                    {
                        out.println(Math.min(index,1));
                    }
                }
            }
            else if(max<0)
            {
                if(n==1)
                {
                    out.println(1);
                }
                else
                {
                    int x=1;
                    for(int i=0;i<list.size()-1;i++)
                    {
                        if(a[list.get(i)]!=x)
                        {
                            break;
                        }
                        else
                        {
                            x++;
                        }
                    }
                    if(x>n)
                    {
                        x=1;
                    }
                    out.println(x);
                }
            }
            else
            {
                out.println(index);
            }
        }
        out.close();
    }
    static 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;
        }
    }
}