import Data.List
import Data.Array
import Control.Monad

main = do
 n <- readLn ::IO Int
 an <- map read . words <$> getLine
 print  (solve n an)

solve :: Int -> [Integer] -> Integer
solve 2 an = abs ((head an) -  (last an))
solve n an = minimum [abs ((bn!!k)*2 - sn) | k <- [1..n-2]]
                       where bn = sumlist an []
                             sn = sum an

sumlist :: [Integer] -> [Integer] -> [Integer]
sumlist (a:an) [] = sumlist an [a]
sumlist [] bn = bn
sumlist (a:an) bn = sumlist an (bn ++ [a+b])
                    where b = last bn