n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
s = [a[0]]
(n-1).times do |i|
  s.push(s[i] + a[i+1])
end

min = 100000000
(n-1).times do |i|
  tmp = (2 * s[i] - s[-1]).abs
  if tmp < min then
    min = tmp
  end
end
  
puts min