n = gets.to_i
xs = []

n.times{
	xs << (gets.split.map &:to_i)
}

def diff_arr (p, arr)
	ret = arr.map{ |a| (a - p).abs }.min
	
	if ret != nil && ret < p.abs then
		ret
	else
		p.abs
	end
end

y_cand = xs.map{ |x| x[0] }.uniq
x_cand = xs.map{ |x| x[1] }.uniq

all_cand = y_cand.map{ |x| [x, 1] } + x_cand.map{ |x| [x, 0] }

#print xs

(3..3).each{ |k|
	if k >= all_cand.size then
		puts 0
	else
		min_sum = Float::INFINITY
	
		all_cand.combination(k).each{ |temp_c|
			cands_x = [2,5]
			cands_y = [-5]

			temp_c.each{ |t|
				if t[1] == 0 then
					cands_x << t[0]
				else
					cands_y << t[0]
				end
			}
			sum = 0

			xs.each{ |x|
				sum += [diff_arr(x[1], cands_x) , diff_arr(x[0], cands_y)].min * x[2]
			}
			
=begin
			print cands_x
			puts
			print cands_y
			puts
			puts sum
=end			
			if min_sum > sum then
				min_sum = sum
			end
		}
		
		puts min_sum
#		puts
	end
}

