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