let rec select acc trace = function
  | [] -> acc
  | x :: xs -> select ((trace, x, xs) :: acc) (x :: trace) xs
let select xs = select [] [] xs

let rec maximize z w xs =
  select xs
  |> List.map (function
        | (_, x, []) -> abs (x - w)
        | (_, x, ys) -> minimize x w ys)
  |> List.fold_left max min_int
and minimize z w ys = 
  select ys
  |> List.map (function
        | (_, y, []) -> abs (z - y)
        | (_, y, xs) -> maximize z y xs)
  |> List.fold_left max min_int

let () =
  let n, z, w = Scanf.scanf "%d %d %d\n" (fun n z w -> n, z, w) in
  let as_ = Array.init n (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  Printf.printf "%d\n" @@ maximize z w (Array.to_list as_)