import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val al = List.fill(n)(sc.nextInt)

  val alSorted = al.sorted

  val res = alSorted.last - alSorted.head

  println(res)
}