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.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.*;

public class C {

	static ArrayList<Integer> l = new ArrayList<Integer>();
	static int res[];
	static int sol = 99999999;
	static int best = -99999999;
	
	public static void main(String[] args) {
		FastScanner in = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		
		int n = in.nextInt();
		int a[] = new int[n];
		res = new int[n+1];
		Arrays.fill(res,0);
		int max = -999999;
		for(int i = 0; i < n; i++){
			a[i] = in.nextInt();
			if(a[i] > max){
				res[a[i]]--;
				max = a[i];
			}
		}
			
		for(int i = 0; i < n; i++){
			go2(a[i]);
		}
		for(int i = 0; i < n; i++){
			if(res[a[i]] > best || (res[a[i]] == best && a[i] < sol)){
				best = res[a[i]];
				sol = a[i];
			}
		}
		
		System.out.println(sol);
		
		
	}
	static void go2(int x){
		int ind = bs2(0, l.size(), x);
		if(ind == l.size()-1){
			int m = l.get(l.size()-1);
			res[m]++;
		}
		l.add(ind, x);
	}
	
	static void go(int x){
		int ind = bs2(0, l.size(), x);
		if(ind < 0) ind = 0;
		if(ind == l.size()){
//			if(res[x] > best || (res[x] == best && x < sol)){
//				best = res[x];
//				sol = x;
//			}
		}
		else if(ind == l.size()-1){
			int m = l.get(l.size()-1);
			res[m]++;
//			if(res[m] > best || (res[m] == best && m < sol)){
//				best = res[m];
//				sol = m;
//			}
		}
		l.add(ind, x);
	}
	
	static int bs(int lo, int hi, int val){
		if(l.size() == 0) return 0;
		if(lo+1 >= hi) return l.get(lo) < val ? hi : lo;
		int mid = (lo+hi)/2;
		int g1 = l.get(mid);
		if(g1 > val) return bs(lo, mid, val);
		if(mid+1 >= l.size()) return l.get(mid) < val ? mid+1 : mid;
		int g2 = l.get(mid+1);
		if(g1 < val && g2 > val) return mid+1;
		else if(g1 > val) return bs(lo, mid, val);
		else return bs(mid, hi, val);
		
	}
	
	static int bs2(int lo, int hi, int val){
		if(l.size() == 0) return 0;
		int mid = (lo+hi)/2;
		int g = l.get(mid);
		if(g > val){
			if(mid == 0) return 0;
			if(l.get(mid-1) < val ) return mid;
			return bs(lo, mid, val);
		}
		else{
			if(mid == l.size()-1) return l.size();
			if(l.get(mid+1) > val ) return mid+1;
			return bs(mid, hi, val);
		}
		
	}

	static class FastScanner{
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(String s) {
			try{
				br = new BufferedReader(new FileReader(s));
			}
			catch(FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		public FastScanner(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		String nextToken()	{
			while(st == null ||!st.hasMoreElements()){
				try {
				st = new StringTokenizer(br.readLine());}
				catch(IOException e) {
					e.printStackTrace();
				}			
			}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(nextToken());
		}
		long nextLong() {
			return Long.parseLong(nextToken());
		}
		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
		String next() {
			return nextToken();
		}
		
	}
	
	
}
