import Data.List

main :: IO ()
main = do
    _ <- getLine
    a <- map read . words <$> getLine :: IO [Int]
    let l = init $ scanl1 (+) a
        r = tail $ scanr1 (+) a
    print . minimum . map (\(i,j) -> abs (i - j)) $ zip l r