fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val sortedNumbers = readLine()
        ?.split(" ")
        ?.map(String::toInt)
        ?.sorted()
        ?: return
    println(sortedNumbers[n - 1] - sortedNumbers[0])
}