n,*b=$<.map &:to_i l,h=1,1<<60 n.times{|i| if i%2==0 l,h=[b[i]-h,1].max,b[i]-l else l,h=[l-b[i],1].max,h-b[i] end } if l>h p -1 else a=[l] (n-1).downto(0){|i|a<