(* O(n * log(n)) *)
let solve n a_s =
  let a_s = Array.of_list a_s in
  Array.sort compare a_s;
  a_s.(n - 1) - a_s.(0)

let read_ints () = read_line () |> Str.split (Str.regexp " ") |> List.map int_of_string

let _ =
  let n = read_int () in
  read_ints () |> solve n |> string_of_int |> print_endline