# frozen_string_literal: true class Array def average Rational(sum, size).to_f end end def solve Y.average.then { |a| [a.floor, a.ceil] }.map { |i| Y.map { |y| (y - i).abs }.sum }.min end N = gets.to_i Y = gets.split.map(&:to_i) puts solve