import Data.List
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  ws <- map read.words<$> getLine :: IO [Int]
  list <- forM [1..n-1] $ \i -> do
    return  (abs $ (sum (take i ws)) - (sum (drop i ws)))
  print $ minimum list
