N = gets.to_i
A = gets.split.map(&:to_i)

sum = A.inject(:+)
ans = Float::INFINITY

left = 0

A[0..-2].each do |a|
  left += a
  right = sum - left

  diff = (left - right).abs

  ans = diff if ans > diff
end

puts ans
