$\+=$_ for(sort{$a<=>$b}map$_-=$a[++$i]//$_,@a=sort{$b<=>$a}glob<>)[<>!~$"..$`-$'];print