import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val a = StdIn.readLine().split(" ").map(_.toLong)

  println(a.max - a.min)
  /* NG
  val r = a.foldLeft((1L, 1L)){ (acc, ai) =>
    val min = scala.math.min(acc._1, ai)
    val max = scala.math.max(acc._2, ai)
    (min, max)
  }
  */
}