open System

let N =stdin.ReadLine()|>int
let W =stdin.ReadLine().Split()|>Array.map int
[<EntryPoint>]
let main argv =
    [for i in [0..N-2] do yield ([0..N-1]|>Seq.sumBy(fun c -> (if c<=i then W.[c] else -(W.[c]))))]
    |>List.map abs
    |>List.min
    |>stdout.WriteLine
    0