def lscan; gets.split.map(&:to_i); end gets;p lscan.sort.each_slice(2).reduce([0,0]){|s,e|s[0]+=e[0];s[1]+=e[1]||0;s}.map(&:abs).reduce(&:-)