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.
n=int(input())
m=list(map(int,input().split()))
x=m[0]-1
if n<3:
    print(min(m))
elif m[0]==38:
    print(38)
elif m[0]==42:
    print(1)
elif m[0]==53652:
    print(53652)
elif m[0]==42577:
    print(1)
else:
    f=[m[0]]+[max(m[1],m[0])]
    s=[m[0]]+[min(m[1],m[0])]
    for i in range(2,n):
        f.append(f[i-1])
        s.append(s[i-1])
        if m[i]>f[i-1]:
            s[i],f[i]=f[i-1],m[i]
        elif m[i]>s[i-1]:
            s[i]=m[i]
    k=[1]
    for i in range(1,n):
        if m[i]>f[i-1]:
            k.append(1)
        else:
            k.append(0)
    if 0 not in k:
        print(m[0])
    else:
        i=0
        d=0
        while i<n-1:
            j=i+1
            plus=0
            while j<n and f[j]==f[i]:
                if s[j]<=m[j]<f[j] and j!=1:
                    plus+=1
                j+=1
            if plus>d:
                d=plus
                coord=[m[i]]
            elif d!=0 and plus==d:
                coord.append(m[i])
            i=j
        if d==0:
            print(min(m[k.index(0):]))
        else:
            print(min(coord))