let n = Scanf.scanf " %d" (+) 0
let ws = Array.init n @@ fun _ -> Scanf.scanf " %d" (+) 0
let s = Array.fold_left (+) 0 ws
let ans = ref max_int
let _ = for t = 0 to n - 2 do let s1 = ref 0 in
  for i = 0 to t do s1 := !s1 + ws.(i) done; ans := min !ans @@ abs @@ s - 2 * !s1 done; Printf.printf "%d\n" !ans