local n = io.read("*n", "*l")
local str = io.read()
local nums = {}
local ti = table.insert
local tn = tonumber
local diff = 0
for numstr in string.gmatch(str, "%-?%d+") do
  local a = tn(numstr)
  diff = diff + a
  ti(nums, a)
end
diff = diff - nums[1] * 2
local ma = math.abs
local mm = math.min
local diffmax = ma(diff)
for i = 2, n - 1 do
  diff = diff - nums[i] * 2
  diffmax = mm(diffmax, ma(diff))
end
print(diffmax)
