n = gets.to_i
a = gets.split.map(&:to_i)
average = 0
def sum(m,array)
  wa = 0
  for i in 0..m
    wa += array[i]
  end
  wa
end

average = sum(n-1,a).to_f/2
for i in 0..(n-2)
  if sum(i,a).to_f == average
    puts 0
  elsif sum(i,a) < average && sum(i+1,a) > average
    x = [(average - sum(i,a)).abs,(average - sum(i+1,a)).abs].min
    puts (2*x).to_i
  end
end