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 = function
  | [] -> abs (z - w)
  | xs ->
      select xs
      |> List.map (fun (_, x, xs) -> minimize x w xs)
      |> List.fold_left max min_int
and minimize z w = function
  | [] -> abs (z - w)
  | xs ->
      select xs
      |> List.map (fun (_, x, xs) -> maximize z x xs)
      |> List.fold_left min max_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_)