import Data.List
main = do
  n <- readLn :: IO Int
  ws <- map (read::String->Int) . words <$> getLine
  print $ balance n ws

balance n ws = minimum [abs y|x<-[1..n], let y=((sum . take x) ws)-((sum . drop x) ws)]