
main::IO()
main= do
    _ <- readLn::IO Int
    a <- map (read::String -> Integer) . words <$> getLine
    let elmnt = drop 1 $ zip (scanl (+) 0 (init a)) (scanr (+) 0 a)
    print $ minimum $ map (abs) $ map (\e -> (fst e - snd e)) elmnt 

