import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

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

