import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import Debug.Trace
main :: IO ()
main = getLine >> readLine >>= print . solve 

solve :: [Int] -> Int
solve ws = minimum . map (\(x, y) -> abs $ x - y) $ zip xs ys
    where
        xs = scanl (+) 0 ws
        ys = scanr (+) 0 ws

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine