let a_s = Array.init (read_int ()) @@ fun _ -> Scanf.scanf " %d" (+) 0
let s = Array.fold_left (+) 0 a_s
let _ = Array.fold_left (fun (m, l) a -> min m @@ abs @@ 2 * l - s, l + a) (max_int, 0) a_s |> fst |> Printf.printf "%d\n"