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.InputStreamReader;

public class codeforces450C {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public void solve() throws IOException {
        int n = pint(br.readLine());
        String[] s = br.readLine().split("\\s+");
        int[] p = new int[n];
        for(int i = 0; i<n; i++){
            p[i] = pint(s[i]);
        }

        bestToRemove3(p, n);
    }

    public void bestToRemove3(int[] p, int n){
        int max1 = -1;
        int max2 = -1;
        int[] lost = new int[n+1];

        for(int i = 0; i<n; i++){
            if(p[i] > max1){
                max2 = max1;
                max1 = p[i];
                lost[max1]--;
            }else if(p[i] > max2){
                max2 = p[i];
                lost[max1]++;
            }
        }

        int best = 1;
        for(int i = 2; i<=n; i++){
            if(lost[i] > lost[best]){
                best = i;
            }
        }
        System.out.println(best);
    }

    public void bestToRemove2(int[] p, int n){
        int[] biggestUntil = new int[n];
        biggestUntil[0] = p[0];
        for(int i = 1; i<n; i++){
            biggestUntil[i] = Math.max(biggestUntil[i-1], p[i]);
        }
        int[] longestInc = new int[n];
        longestInc[0] = 1;
        for(int i = 1; i<n; i++){
            longestInc[i] = longestInc[i-1];
            if(p[i] > biggestUntil[i-1]) longestInc[i]++;
        }

        int best = n+1;
        int bestCount = -1;
        for(int i = 0; i<n; i++){
            //try to throw away i
            int count = 0;
            if(i != 0) count += longestInc[i-1];
            //if there is still enough remaining elements to do better
            //and if enough of those elements are actually possible to be bigger than the biggest so far
            int biggest = 0;
            if(i != 0) biggest = biggestUntil[i-1];

            if(bestCount - count <= n-i-1 && bestCount - count <= biggestUntil[n-1] - biggest) {
                count += recCount(biggest, i + 1, n, p);
                if (bestCount < count) {
                    bestCount = count;
                    best = p[i];
                } else if (bestCount == count) {
                    best = Math.min(best, p[i]);
                }
            }
        }
        System.out.println(best);
    }

    public int recCount(int biggest, int i, int n, int[] p){
        int count = 0;
        for(int k = i; k<n; k++){
            if(p[k] > biggest){
                count++;
                biggest = p[k];
            }
        }
        return count;
    }


    public void bestToRemove(int[] p, int n){
        int best = n+1;
        int bestRecordCount = -1;
        for(int i = 0; i<n; i++){
            int r = records(i, p);
            if(r > bestRecordCount){
                bestRecordCount = r;
                best = p[i];
            }else if(r == bestRecordCount){
                best = Math.min(best, p[i]);
            }
        }
        System.out.println(best);
    }

    public int records(int withoutI, int[] A){
        int sum = 0;
        int biggest = -1;
        for(int i = 0; i<A.length; i++){
            if(i == withoutI)continue;
            if(A[i] > biggest){
                sum++;
                biggest = A[i];
            }
        }
        return sum;
    }

    int pint (String s){
        return Integer.parseInt(s);
    }

    long plong (String s){
        return Long.parseLong(s);
    }

    public static void main(String[] args) {
        try {
            new codeforces450C().solve();
        }catch (IOException e){
            e.printStackTrace();
        }
    }
}
