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.*;

public class Main {
		
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		
		int n = sc.nextInt();
		int[] val = new int[n];
		int[] extra = new int[n];
		boolean[] isRecord = new boolean[n];
		int records = 0;
		for (int i=0; i<n; i++) {
			val[i] = sc.nextInt();
		}
		
		int hi1 = -1; int ihi1 = -1;
		int hi2 = -1; int ihi2 = -1; // hi2 >= hi1

		for (int i=0; i<n; i++) {
			int a = val[i];
			if (a > hi2) {
				isRecord[i] = true;
				records++;
			}
			if (a > hi1 && a <= hi2) {
				extra[ihi2]++;
			}
			if (a > hi2) {
				hi1 = hi2; ihi1 = ihi2;
				hi2 = a;   ihi2 = i;
			} else if (a > hi1) {
				hi1 = a;   ihi1 = i;
			}
		}
		
		int best = -1;
		int valbest = -1;
		for (int i=0; i<n; i++) {
			int trial = extra[i] + records + (isRecord[i] ? -1 : 0);
			if (trial > best || (trial == best && val[i] < valbest)) {
				best = trial;
				valbest = val[i];
			}
		}
		System.out.println(valbest);
	}

}