module Main where

import Data.List


main :: IO ()
main = do
  n <- read <$> getLine
  inputs <- (map read . words) <$> getLine
  print $ minimum (map (\x -> abs $ (sum (take x inputs)) - (sum (drop x inputs))) [0..n])