-- Question C Time Over

import Control.Applicative
import Control.Monad

main = do
  n <- readLn ::IO Int
  xs <- map read . words <$> getLine 
  putStr $ show ( memo xs n )
  
sunuke i xs = sum ( take i xs)
memo xs n = minimum [abs ( 2*(sunuke i xs) - (sum xs)) | i <-[1..(n-1)] ]

