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

public class Main
{
	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;
        }
    }

	public static void main (String[] args)
	{
		int i, j;
		FastReader reader = new FastReader();
		int totalElements = reader.nextInt();
		int[] array = new int[totalElements];
		int[] hash = new int[totalElements+1];
		int[] indexing = new int[totalElements+1];

		for (i=0; i<totalElements; i++)
		{
			array[i] = reader.nextInt();
			indexing[array[i]] = i+1;
		}

		PriorityQueue<Integer> heap = new PriorityQueue<Integer> (new TopPriority());
		heap.add (array[0]);
		if (totalElements > 1)
			heap.add (array[1]);

		for (i=2; i<totalElements; i++)
		{
			int temp = heap.remove();

			if (temp > array[i] && heap.peek() < array[i])
				hash[temp]++;

			if (array[i] > temp)
				hash[array[i]]--;

			heap.add (temp);
			heap.add (array[i]);
		}
		if (totalElements > 1)
		{
			if (array[0] < array[1])
			{
				hash[array[0]]--;
				hash[array[1]]--;
			}
		}

		int max = Integer.MIN_VALUE, index = totalElements;
		for (i=1; i<=totalElements; i++)
		{
			///*if (i==38 || i==48)
			//System.out.println (hash[i] + " erye");

			if (max < hash[i])
			{
				max = hash[i];
				index = i;
			}
			else if (max == hash[i])
				index = Math.min (index, i);
		}

		System.out.println (index);
	}
}

class TopPriority implements Comparator<Integer>
{
	public int compare (Integer a, Integer b)
	{
		return (b-a);
	}
}
