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.
//I AM THE CREED
/* //I AM THE CREED
/* package codechef; // don't place package name! */
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.StringTokenizer; 
import java.util.*;
import java.awt.Point;
public class Main{
    
    public static void main(String[] args) throws IOException 
    { 
        
        FastScanner input = new FastScanner();
        int n=input.nextInt();
        int[] record=new int[n];
        int[] record2=new int[n];
        int[] l=new int[n];
        for(int i=0;i<n;i++){
            l[i]=input.nextInt();
        }
        int max1=l[0];
        int max2=0;
        record[0]=1;
        record2[0]=1;
        for(int i=1;i<n;i++){
            record[i]=record[i-1];
            record2[i]=record2[i-1];
            if(l[i]>max1){
                record[i]++;
            }
            if(l[i]>max2){
                record2[i]++;
            }
            if(max1>l[i]){
                max2=Math.max(max2, l[i]);
            }
            if(l[i]>max1){
                max2=max1;
                max1=l[i];
            }
        }
        Stack<Integer> st=new Stack<>();
        int[] nextGreater=new int[n];
        Arrays.fill(nextGreater, n);
        for(int i=0;i<n;i++){
            while(st.size()!=0 && l[i]>l[st.peek()]){
                nextGreater[st.peek()]=i;
                st.pop();
            }
            st.push(i);
        }
        int ans=l[0];
        int records=(record[n-1]-record[nextGreater[0]-1]+record2[nextGreater[0]-1]-record2[0]);
        for(int i=1;i<n;i++){
            int curr=0;
            if(i==n-1){
                curr=record[i-1];    
            }
            if(i<n-1){
                curr=record[i-1]+(record[n-1]-record[nextGreater[i]-1]+record2[nextGreater[i]-1]-record2[i]);
            }
            if(records<curr){
                records=curr;
                ans=l[i];
            }
            if(records==curr){
                ans=Math.min(ans, l[i]);
            }
        }
        System.out.println(ans);
            
    }
    static boolean isPrime(int n) 
    { 
        // Corner case 
        if (n <= 1) 
            return false; 
  
        // Check from 2 to n-1 
        for (int i = 2; i < n; i++) 
            if (n % i == 0) 
                return false; 
  
        return true; 
    } 
    static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}
 
}
