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.io.PrintWriter;
import java.util.*;
import java.math.*;
import java.util.InputMismatchException;
public class solution{
	public static void main(String args[]) throws Exception 
		{
			InputReader sc = new InputReader(System.in);
			PrintWriter out = new PrintWriter(System.out);
			int n = sc.nextInt();
			int[] p = new int[n];
			for(int i=0;i<n;i++)
			{
				p[i] = sc.nextInt();
			}
			if(n==1)
			{
				System.out.println(p[0]);
				return;
			}
			int[] x = new int[n];
			x[0] = 1;
			int max = p[0];
			for(int i=1;i<n;i++)
			{
				if(p[i]>max)
				{
					x[i] = 1;
					max = p[i];
				}	
			}
			int[] r = new int[n];
			int max1 = 0;
			int max2 = 0;
			int ind1 = 0;
			if(p[1]<p[0])
			{
				r[0]++;
				max1 = p[0];
				max2 = p[1];
				ind1 = 0;
			}
			else
			{
				max1 = p[1];
				max2 = p[0];
				ind1 = 1;
			}
			for(int i=2;i<n;i++)
			{
				if(x[i]==0)
				{
					if(p[i]>max2)
					{
						r[ind1]++;
						max2 = p[i];
					}
				}
				else
				{
					max2 = max1;
					max1 = p[i];
					ind1 = i;
				}
			}
			max = Integer.MIN_VALUE;
			int elem = Integer.MAX_VALUE;
			for(int i=0;i<n;i++)
			{
				r[i]-=x[i];
				if(r[i]>max)
				{
					max = r[i];
					elem = p[i];
				}
				else if(r[i]==max&&p[i]<elem)
				{
					elem = p[i];
				}
			}
			out.println(elem);
			out.close();
		}
	static class InputReader {
		 
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;
 
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
 
        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }
 
        public String readString() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = snext();
            } while (!isSpaceChar(c));
            return res.toString();
        }
 
        public int[] readCharCount() {
            int c = snext();
            while (isSpaceChar(c))
                c = snext();
            int[] map = new int[256];
            do {
                int val = c ;
                map[val]++;
                c = snext();
            } while (!isSpaceChar(c));
            return map;
        }
 
        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
 
} 
