import java.util.Scanner

object Main{
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt
    val array = List.fill(n)(sc.nextInt)
    val max = array.max
    val min = array.min
    println(max-min)
  }
}