b = gets.to_i n = gets.to_i c = STDIN.map(&:to_i) avarage = c.inject(&:+) / n p c.map{|candy|(candy - avarage).abs}.inject(&:+)