eval"N,A,*B="+gets(p).split*?, x=A p B.map{|c|-A+A=c}.min,B[-1]-x