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

import java.util.Scanner;

public class Main{
    public static void main(String[] args) throws FileNotFoundException {
        Scanner scanner = new Scanner(System.in);
        int n=scanner.nextInt();
        int num[] = new int[n+5];
        for(int i=1;i<=n;i++){
            num[i]=scanner.nextInt();
        }

        int mx1,mx2;
        mx1=mx2=Integer.MIN_VALUE;
        int record[] = new int[n+5];
        for(int i=1;i<=n;i++){
            if(num[i]<mx1&&num[i]>mx2){
                record[mx1]++;
            }
            if(num[i]>mx1){
                record[num[i]]--;
            }
            if(num[i]>mx2){
                mx2=num[i];
            }
            if(mx2>mx1){
                int tmp = mx2;
                mx2=mx1;
                mx1=tmp;

            }
//            System.out.println("mx1 = " + mx1);
//            System.out.println("mx2 = " + mx2);
//            System.out.println();
        }

        int ans = Integer.MIN_VALUE;
        for(int i=1;i<=n;i++){
            ans=Math.max(ans,record[i]);
        }

        for(int i=1;i<=n;i++){
            if(record[i]==ans){
                System.out.println(i);
                break;
            }
        }
    }
}

class Tree{
    int num[];
    int size;
    int tot;
    public Tree(int size) {
        this.size=size;
        num = new int[size+5];
        tot=0;
    }

    private int lowbit(int x){
        return x&-x;
    }

    private int query(int x){
        int ans = 0;
        while (x!=0){
            ans+=num[x];
            x-=lowbit(x);
        }
        return ans;
    }

    public void update(int x){
        tot++;
        while (x<=size){
            num[x]++;
            x+=lowbit(x);
        }
    }

    public int get(int x){
        return tot-query(x);
    }

}