fun main(args: Array<String>) {
    maximumDifference()
}

fun maximumDifference() {
    val n = readLine()!!.toInt()
    val numList = readLine()!!.split(" ").filter { it != "" }.map { it.toInt() }

    if (n != numList.size) return

    println(numList.max()!!.minus(numList.min()!!))
}