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.Arrays;
import java.util.BitSet;
import java.util.Scanner;
import java.util.StringTokenizer;

public class C2 {
	public static Scanner sc = new Scanner(System.in);
	public static StringTokenizer st;
	public static void main(String[] args) {
		int eles = getInt();
		int[] nums = readArray(eles);
		int[] violators = new int[eles];
		BitSet CurrentList = new BitSet();
		int max = -1;
		for(int i = 0;i<eles;i++){
			int above = CurrentList.get(nums[i], eles +3).cardinality();
			if(above == 1){
				//System.out.println(nums[i] + " doesnt like "+);
				violators[max - 1] += 1;
			}
			else if(above == 0){
				violators[nums[i] - 1] -= 1;
			}
			CurrentList.set(nums[i]);
			max = Math.max(nums[i], max);
		}
		
		int maxele = 1;
		int maxval = -1;
		for(int i = 0;i<eles;i++){
			if(maxval < violators[i]){
				maxval = violators[i];
				maxele = i+1;
			}
			else if(maxval == violators[i] && i+1 < maxele){
				maxele= i+1;
			}
		}
		//System.out.print(Arrays.toString(violators));
		System.out.println(maxele);
	}
	public static int getInt(){
		if (st != null && st.hasMoreTokens()){
			return Integer.parseInt(st.nextToken());
		}
		st = new StringTokenizer(sc.nextLine());
		return Integer.parseInt(st.nextToken());
	}
	public static long getLong(){
		if (st != null && st.hasMoreTokens()){
			return Long.parseLong(st.nextToken());
		}
		st = new StringTokenizer(sc.nextLine());
		return Long.parseLong(st.nextToken());
	}
	public static double getDouble(){
		if (st != null && st.hasMoreTokens()){
			return Double.parseDouble(st.nextToken());
		}
		st = new StringTokenizer(sc.nextLine());
		return Double.parseDouble(st.nextToken());
	}
	public static String getString(){
		if(st != null && st.hasMoreTokens()){
			return st.nextToken();
		}
		st = new StringTokenizer(sc.nextLine());
		return st.nextToken();
	}
	public static String getLine(){
		return sc.nextLine();
	}
	public static int[][] readMatrix(int lines,int cols){
		int[][] matrr = new int[lines][cols];
		for (int i = 0;i < lines;i++){
			for(int j = 0;j < cols;j++){
				matrr[i][j] = getInt();
			}
		}
		return matrr;
	}
	public static int[] readArray(int lines){
		int[] ar = new int[lines];		
		for (int i = 0;i<lines;i++) ar[i] =getInt();
		return ar;
	}
	
}
