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

public class C {
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n = fr.nextInt();
		if(n < 2) {
			System.out.println(1);
			return;
		}
		int[] ia = new int[n];
		int[] premax = new int[n];
		int[] premax2 = new int[n]; 
		ia[0] = fr.nextInt();
		premax[0] = ia[0];
		ia[1] = fr.nextInt();
		if(ia[1] > premax[0]){
			premax2[1] = premax[0];
			premax[1] = ia[1];
		}else{
			premax2[1] = ia[1];
			premax[1] = premax[0];
		}
		for(int i = 2; i < n; i++){
			ia[i] = fr.nextInt();
			if(ia[i] > premax[i-1]){
				premax2[i] = premax[i-1];
				premax[i] = ia[i];
			}else if(ia[i] > premax2[i-1]){
				premax2[i] = ia[i];
				premax[i] = premax[i-1];
			}else{
				premax2[i] = premax2[i-1];
				premax[i] = premax[i-1];
			}
		}
		int[] count = new int[n+1];
		for(int i = 0; i < n; i++){
			if(premax2[i] == ia[i]){
				count[premax[i]]++;
			}
		}
		int maxIndex = n+1;
		for(int i = 0; i < n; i++){
			if(ia[i] != premax[i] && ia[i] < maxIndex) {
				maxIndex = ia[i];
			}
		}
		if(maxIndex == n+1) maxIndex = 1;
		for(int i = 2; i < n+1; i++){
			if(count[i] > count[maxIndex] && count[i] > 1) maxIndex = i;
		}
		System.out.println(maxIndex);
	}
}

class FastReader{
	BufferedReader br;
	StringTokenizer st;

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

	String next(){
		while(st==null || !st.hasMoreTokens()){
			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;
	}
}

//source: http://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/