import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    getLine
    ws <- getIntList
    let ls = scanl (+) 0 ws
    let rs = scanr (+) 0 ws
    print . minimum $ zipWith (\l r -> abs (l - r)) ls (reverse rs)