main = do
    n <- readLn :: IO Int
    ws <- map read . words <$> getLine
    print $ solve ws

solve :: [Int] -> Int
solve ws = minimum ys where
  xs = scanl1 (+) ws
  ys = [abs $ 2 * x - sum ws | x <- xs]
