open Str

let read_list f =
  split (regexp " +") (read_line ()) |> List.map f
                                                 
let () =
  let n = read_int () in
  let xs = read_list int_of_string in
  let sxs = List.sort compare xs in
  let d = List.nth sxs (n-1) - List.hd sxs in
  string_of_int d |> print_endline
                                       
