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.
//Solution following the editorial: Let r_i be if it's a record, x_i:=-r_i be the benefit of removing a_i.
// We will keep the top 2 numbers a_i, a_k as we loop through a_j, updating along the way. If a_i>a_j>a_k, then x_i++.
import java.util.*;

public class Extra2 {
	public static void main(String[] args) {
		Scanner f = new Scanner(System.in);
		int n = f.nextInt(), max = 0;
		int[] a = new int[n], r = new int[n], x = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = f.nextInt();
			if (a[i] > max) {
				max = a[i];
				r[i] = 1;
			}
		}
		for (int i = 0; i < n; i++) {
			x[i] = -1 * r[i];
		}
		max = -1;
		int max2 = -1;
		for (int i = 0; i < n; i++) {
			if (max == -1) max = i;
			else if (max2 == -1) {
				if (a[max] > a[i]) {
					x[max]++; max2 = i;
				} else {
					max2 = max; max = i;
				}
			}
			else {
				if (a[i] > a[max]) {
					max2 = max;
					max = i;
				} else if (a[i] > a[max2]) {
					x[max]++;
					max2 = i;
				}
			}
		}
//		System.out.println(Arrays.toString(r));
//		System.out.println(Arrays.toString(x));
		max = 0;
		for (int i = 1; i < n; i++) {
			if (x[i] > x[max] || (x[i] == x[max] && a[i] < a[max])) max = i;
		}
		System.out.println(a[max]);
	}
}
