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.PrintWriter;
import java.util.Scanner;
import java.util.TreeSet;

public class C2 {
	public void solve(Scanner in, PrintWriter out) {
		int n = in.nextInt();
		int[] a = new int[n];
		TreeSet<Integer> vals = new TreeSet<>();
		int records = 0;
		boolean[] isRecord = new boolean[n];
		int[] remRec = new int[n + 1]; //if k is removed, how many records will it make?
		for(int i = 0; i < n; ++i) {
			a[i] = in.nextInt();
			if(vals.higher(a[i]) == null) {
				++records;
				isRecord[i] = true;
			} else {
				int greater = vals.higher(a[i]);
				if(vals.higher(greater) == null) {
					remRec[greater]++;
				}
			}
			vals.add(a[i]);
		}
		int maxRecs = -1;
		int ans = -1;
		for(int i = 0; i < n; ++i) {
			//removing this...
			int curRec = records;
			if(isRecord[i]) {
				curRec--;
				curRec += remRec[a[i]];
			}
			if(curRec > maxRecs) {
				maxRecs = curRec;
				ans = a[i];
			} else if(curRec == maxRecs) {
				ans = Math.min(ans, a[i]);
			}
		}
		
		out.println(ans);
		
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		new C2().solve(in, out);

		in.close();
		out.close();
	}
}
