object Main extends App {
  readInt
  val (min, max) = readLine.split(" ")
    .map(_.toInt)
    .foldLeft((Int.MaxValue, Int.MinValue): (Int, Int))((acc, h) => (math.min(acc._1, h), math.max(acc._2, h)))
  println(max - min)
}
