local n = io.read("*n")
local sum = {}
sum[1] = io.read("*n")
for i = 2, n do
  local a = io.read("*n")
  sum[i] = a + sum[i - 1]
end
local mab, mmi = math.abs, math.min
local ret = mab(sum[n] - sum[1] - sum[1])
for i = 2, n - 1 do
  ret = mmi(ret, mab(sum[n] - sum[i] - sum[i]))
end
print(ret)
