@0=@1=!<>;/ /,@$c=sort{$a<=>$b}map{$_+$`,$_-$'}@{$c^=1}for<>;$_=$0[0]+$1[-1],$b>abs|???$b=abs:/-/?shift@0:pop@1while@0*@1;print$b