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.util.*;
import  java.math.*;
public class Main {
	public static void main(String[] args) throws IOException
	{
		// StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		FastScanner sc = new FastScanner();
		int n, x, imaxx=-(int)1e9,imax=-(int)1e9, ans=1;
		int a[]=new int[(int)1e5+30];
		n=sc.nextInt();
		for(int i=1; i<=n; ++i)
		{
			x=sc.nextInt();
			if(x > imaxx) {imax=imaxx;imaxx = x; a[x]=-1;}
			else if(x > imax) {++a[imaxx]; imax = x;}
		}
		for(int i=1; i<=n; ++i)
			if(a[i] > a[ans])
				ans = i;
		out.println(ans);



		out.flush();
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		private FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				st = new StringTokenizer(br.readLine());
			} catch (Exception e){e.printStackTrace();}
		}
		private boolean hasNextToken()
		{
			if(st.countTokens()!=StreamTokenizer.TT_EOF)
			{
				return true;
			}
			else
				return false;
		}
		private String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}
		private BigInteger nextBigInteger(){return new BigInteger(next());}
		private BigDecimal nextBigDecimal(){return new BigDecimal(next());}
		private  int nextInt() {return Integer.parseInt(next());}
		private long nextLong() {return Long.parseLong(next());}
		private double nextDouble() {return Double.parseDouble(next());}
		private String nextLine() {
			String line = "";
			if(st.hasMoreTokens()) line = st.nextToken();
			else try {return br.readLine();}catch(IOException e){e.printStackTrace();}
			while(st.hasMoreTokens()) line += " "+st.nextToken();
			return line;
		}
		private int[] nextIntArray(int n) {
			int[] a = new int[n];
			for(int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		private long[] nextLongArray(int n){
			long[] a = new long[n];
			for(int i = 0; i < n; i++) a[i] = nextLong();
			return a;
		}
		private double[] nextDoubleArray(int n){
			double[] a = new double[n];
			for(int i = 0; i < n; i++) a[i] = nextDouble();
			return a;
		}
		private char[][] nextGrid(int n, int m){
			char[][] grid = new char[n][m];
			for(int i = 0; i < n; i++) grid[i] = next().toCharArray();
			return grid;
		}
		private void sort(int arr[])
		{
			int cnt[]=new int[(1<<16)+1];
			int ys[]=new int[arr.length];
			for(int j=0;j<=16;j+=16){
				Arrays.fill(cnt,0);
				for(int x:arr){cnt[(x>>j&0xFFFF)+1]++;}
				for(int i=1;i<cnt.length;i++){cnt[i]+=cnt[i-1];}
				for(int x:arr){ys[cnt[x>>j&0xFFFF]++]=x;}
				{ final int t[]=arr;arr=ys;ys=t;}
			}
			if(arr[0]<0||arr[arr.length-1]>=0)return;
			int i,j,c;
			for(i=arr.length-1,c=0;arr[i]<0;i--,c++){ys[c]=arr[i];}
			for(j=arr.length-1;i>=0;i--,j--){arr[j]=arr[i];}
			for(i=c-1;i>=0;i--){arr[i]=ys[c-1-i];}
		}
	}

}


