[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let n = read int
    let ws = reads int
    let s12 = List.sum ws
    let s1s = List.scan (+) 0 ws |> List.tail
    let ss = List.map (fun s1 -> let s2 = s12 - s1 in abs (s1 - s2)) s1s
    printfn "%i" (List.min ss)
    0