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.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {
	
	public static void main(String[] args) {
		FastScanner input = new FastScanner(System.in);
		
		int N = input.nextInt();
		
		int[] arr = new int[N];
		
		for (int i = 0; i < N; i++)
			arr[i] = input.nextInt() - 1;
		
		BIT tree = new BIT(N);
		
		int[] num = new int[N];
		
		for (int i = 0; i < N; i++) {
			tree.add(arr[i], 1);
			num[i] = i - tree.sum(arr[i] - 1);
		}
		
		int base = 0;
		
		for (int i = 0; i < N; i++)
			if (num[i] == 0)
				base++;
		
		tree = new BIT(N);
		
		int max = -1;
		int small = Integer.MAX_VALUE;
		
		for (int i = N - 1; i >= 0; i--) {
			if (num[i] == 1)
				tree.add(arr[i], 1);
			int amount = base + tree.sum(arr[i] - 1) - (num[i] == 0 ? 1 : 0);
			if (amount > max) {
				max = amount;
				small = arr[i];
			} else if (amount == max)
				small = Math.min(small, arr[i]);
		}
		
		System.out.println(small + 1);
	}
	
	static class BIT {
		int N;
		int[] tree;
		
		BIT(int N) {
			this.N = N;
			tree = new int[N];
		}
		
		void add(int i, int value) {
			while (i < N) {
				tree[i] += value;
				i |= (i + 1);
			}
		}
		
		int sum(int i) {
			int sum = 0;
			while (i >= 0) {
				sum += tree[i];
				i = (i & (i + 1)) - 1;
			}
			return sum;
		}
	}
	
	// Matt Fontaine's Fast IO
	static class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}
