import java.util.Scanner

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

  val n = sc.nextInt()

  val ar = Range(0, n).map(_ => sc.nextInt())
    .sorted
    .toArray

  println(ar(n - 1) - ar(0))
}
