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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.TreeMap;


public class a {
	static int n,m;
	static boolean[] match;
	static int[] rs;
	static long MOD = (long) (1e9+7);
	public static void main(String[] args) throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		TreeMap<Integer, Integer> ts = new TreeMap<>();
		int n = in.nextInt();
		int[] vs = new int[n];
		int[] cnts = new int[n];
		int[] parCnts = new int[n];
		BIT bit = new BIT(n);
		int ans = 0;
		for(int i=0;i<n;i++) {
			vs[i] = in.nextInt();
			int cnt = i-bit.read(vs[i]-1);
			cnts[i] = cnt;
			if(cnt == 1) {
				int hg = ts.higherEntry(vs[i]).getValue();
				parCnts[hg]++;
			}
			if(cnt == 0){
				ans++;
			}
			bit.update(vs[i], 1);
			ts.put(vs[i], i);
		}
		int max = -1;
		int maxIdx = -1;
		for(int i=0;i<n;i++) {
			int tmp = ans - (cnts[i] == 0 ? 1 : 0) + parCnts[i];
			if(tmp > max || (tmp == max && vs[i] < maxIdx)) {
				max = tmp;
				maxIdx = vs[i];
			}
		}
		System.out.println(maxIdx);
	}
	static class BIT {
		int n;
		int[] tree;
		int[] indices; // Used for compressed BIT //%
		
		public BIT(int n) {
			this.n = n;
			tree = new int[n + 1];
		}
		
		int read(int i) {
			i++;
			int sum = 0;
			while (i > 0) {
				sum += tree[i];
				i -= i & -i;
			}
			return sum;
		}
		
		void update(int i, int val) {
			i++;
			while (i <= n) {
				tree[i] += val;
				i += i & -i;
			}
		}
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream i) {
			br = new BufferedReader(new InputStreamReader(i));
			st = null;
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			if (st == null) {
				st = new StringTokenizer(br.readLine());
			}
			String line = st.nextToken("\n");
			st = null;
			return line;
		}

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

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

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