object Main extends App {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt
	val as = Array.fill(N)(sc.nextInt)
    
    val d = as.reduceLeft(_ max _) - as.reduceLeft(_ min _)
    
    println(d)
}