def g (xs,m) return xs.inject(0){|sum,e| sum+(m-e).abs } end n=gets.to_i xs=gets.split.map{|e| e.to_i}.sort if xs.size==1 puts 0 else d1=g(xs,xs[xs.size/2]) d2=g(xs,xs[xs.size/2+1]) if(d1