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 -> [Int] -> Int
solve 2 an = abs ((head an) -  (last an))
solve n an = minimum [abs ((bn!k)*2 - sn) | k <- [1..n-2]]
                       where bn = array (0,n-1) ( (0, (an !! 0)) : [(k , ((an !! k) + bn!(k-1) )) | k <- [1,2..n-1]])
                             sn = sum an
