open Batteries

let _ = read_int ()
let xs = read_line ()
  |> String.split_on_char ' '
  |> List.map int_of_string
  |> List.sort compare;;

(List.nth xs (List.length xs - 1)) - List.nth xs 0
  |> string_of_int
  |> print_endline