import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    scn.nextLine().toInt()
    val numbers = scn.nextLine().split(" ").map { it -> it.toInt() }
    println(numbers.max()!!.toInt() - numbers.min()!!.toInt())

}