import sys readline=sys.stdin.readline N=int(readline()) M=[int(readline()) for i in range(N)] inf=1<<30 dp=[inf]*(1<