let n = Scanf.scanf " %d" (+) 0
let ws = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let ans = ref max_int
let _ =
  for t = 1 to n - 1 do
    let s1, s2 = ref 0, ref 0 in
    Array.iteri (fun i w -> if i + 1 <= t then s1 := !s1 + w else s2 := !s2 + w) ws;
    ans := min !ans @@ abs @@ !s1 - !s2 done;
  Printf.printf "%d\n" !ans