(*
ocamlfind ocamlopt -package batteries -linkpkg main.ml -o a.out
*)
open Batteries

let n = Scanf.sscanf (read_line ()) "%d" (
        fun n -> 
                n
)

let array = Str.split (Str.regexp " ") (read_line ())
            |> List.map int_of_string 
            |> List.sort compare
            |> Array.of_list

let () =
        (
                let lmax = Array.max (Array.sub array 0 (n / 2)) in
                let rmin = Array.min (Array.sub array (n / 2) (n / 2)) in
                        if lmax = rmin then
                                0
                        else
                                List.range lmax `To (rmin - 1)
                                |> List.length
        ) |> Printf.printf "%d\n"
