main = print . solve . map read . drop 1 . words =<< getContents

solve :: [Integer] -> Integer
solve xs =
    let summed = drop 1 $ scanl (+) 0 xs
    in  minimum . map (\x -> abs $ (last summed) - x - x) $ init summed
