n = gets.to_i
w = gets.split.map(&:to_i)
ans = 10**4 + 1

(0..100).each do |i|
  a = 0
  b = 0
  n.times do |j|
    a += w[j] - i if w[j] > i
    b += i - w[j] if w[j] < i
  end
  ans = (a - b).abs if (a - b).abs < ans
end

puts ans
