local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local mab = math.abs
local n = io.read("*n")
local w = {}
for i = 1, n do w[i] = io.read("*n") end
local sum = {}
sum[1] = w[1]
for i = 2, n do
  sum[i] = sum[i - 1] + w[i]
end
local dif = mab((sum[n] - sum[1]) - sum[1])
for i = 2, n - 1 do
  local adif = mab((sum[n] - sum[i]) - sum[i])
  dif = mmi(dif, adif)
end
print(dif)
