let () =
  let n = Scanf.scanf "%d\n" (fun n -> n) in
  let a = Scanf.scanf "%d " (fun a -> a) in
  let as_ = Array.init (n - 2) (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let a' = Scanf.scanf "%d " (fun a' -> a') in
  Array.fold_left (fun (minimum, x, y) a ->
    (min minimum (abs (x - y)), x + a, y - a))
    (max_int, a, Array.fold_left ( + ) a' as_) as_
  |> (fun (minimum, x, y) -> min minimum (abs (x - y)))
  |> Printf.printf "%d\n"