import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()

fun main(args: Array<String>) {
    var aEnd = Int.MIN_VALUE
    var aStart = Int.MAX_VALUE

    for (i in 1..N) {
        val a = sc.nextInt()
        aEnd = Math.max(aEnd, a)
        aStart = Math.min(aStart, a)
    }
    println(aEnd - aStart)
}
