import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine.toInt
  val a0 = StdIn.readLine.split(" ")
  val a1 = a0.map(_.toInt)

  val max = a1.max
  val min = a1.min

  println(max - min)
}