import scala.math.abs

object Main {
  def main(args:Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val as = List.fill(n)(sc.nextInt)

    println(abs(as.max - as.min))
  }
}