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 sys, math
from sys import stdin, stdout
from bisect import  bisect_left
from collections import deque
rem = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, stdin.readline().split())


p={}


n=input()
arr=take()
if n==1:
    print 1
    exit()
for i in range(1,n+1):
    p[i]=0
m=[0,arr[0]]
rec={}
r=[0 for i in range(n)]
for i in range(1,n):
    m.append(arr[i])
    m.sort()
    m=m[1:]
    if arr[i]==m[0]:
        p[m[1]]+=1
    elif m[1]==arr[i]:
        r[i]=1
#print r
#print p
tot=sum(r)
fin={}
for i in range(1,n+1):
    fin[i]=0

a=arr[0]
b=arr[1]
fin[a]=tot+p[a]

fin[a]-=1
for j in range(1,n):
    i=arr[j]
    fin[i]=tot-r[j]+p[i]
#print fin
ans=[]
m=-1
for i in range(1,n+1):
    if fin[i]>m:
        m=fin[i]
        ans=[i]
    elif fin[i]==m:
        ans.append(i)
print ans[0]



