import sys input=lambda: sys.stdin.readline().rstrip() n=int(input()) M=[int(input()) for _ in range(n)] inf=10**9 P=[inf]*(1<