let id x = x
let n = Scanf.scanf "%d\n" id

let array = Array.init n (fun _ -> Scanf.scanf "%d " id)
let () = Array.sort compare array  

let ans = array.(n-1) - array.(0)

let () =
  Printf.printf "%d\n" ans