let n = stdin.ReadLine() |> int
let a = stdin.ReadLine().Split() |> Array.map int
[for i in 1..n -> abs (((a |> Array.sum) - (a |> Array.take i |> Array.sum)) - (a |> Array.take i |> Array.sum))] |> List.min |> printfn "%d"