open Batteries

let read_two () = Scanf.sscanf (read_line ()) "%d %d" (fun a b -> (a, b))

let read_three () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c -> (a, b, c))

let read_four () =
  Scanf.sscanf (read_line ()) "%d %d %d" (fun a b c d -> (a, b, c, d))

let read_list () =
  read_line () |> String.split_on_char ' '
  |> List.map (fun s -> int_of_string s)

(* a**x *)
let pow a x =
  let rec aux acc = function 0 -> acc | n -> aux (acc * a) (n - 1) in
  aux 1 x

let rec pow2 n = if n mod 2 = 0 then 1 + pow2 (n / 2) else 0

let rec f n = function
  | d1 :: d2 :: rest -> if n = 1 then (d1, d2) else f (n - 2) rest
  | _ -> invalid_arg "list smaller than n/2"

let () =
  let n = read_int () in
  let d = read_list () |> List.sort compare in
  let a, b = f (n / 2) d in
  print_int (b - a);
  print_newline ()
