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.
/**
 * DA-IICT
 * Author : Savaliya Sagar
 */
import java.io.*;
import java.math.*;
import java.util.*;

public class C900 {
	void solve() {
		int n = ni();
		int m1 = 0;
		int m2 = 0;
		int a[] = new int[n + 1];
		int c[] = new int[n + 1];
		int r[] = new int[n + 1];
		Arrays.fill(r, 1);
		for (int i = 1; i <= n; i++) {
			a[i] = ni();
			if (a[i] > a[m1]) {
				m2 = m1;
				m1 = i;
			} else if (a[i] > a[m2]) {
				m2 = i;
				c[a[m1]]++;
				r[i] = 0;
			}else
				r[i] = 0;
		}
		tr(r);
		tr(c);
		int min = Integer.MAX_VALUE;
		int max = Integer.MIN_VALUE;
		for (int i = 1; i <= n; i++) {
			int cur = -r[i] + c[a[i]];
			tr(cur);
			if ( cur>max || (cur == max &&  min > a[i])) {
				max = cur;
				min = a[i];
			}
		}
		out.println(min);
	}
	void run() throws Exception {
		out = new PrintWriter(System.out);
		reader = new BufferedReader(new InputStreamReader(System.in), 32768);
		tokenizer = null;
		solve();
		out.flush();
	}
	public int ni() {
		return Integer.parseInt(next());
	}

	BufferedReader reader;
	StringTokenizer tokenizer;
	PrintWriter out;
	public static void main(String[] args) throws Exception {
		new C900().run();
	}
	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	private void tr(Object... o) {
		if (debug == 1)
			System.out.println(Arrays.deepToString(o));
	}
	int debug = 0;
}
