import java.util.*

fun main(args: Array<String>) {
    val scan = Scanner(System.`in`)
    var kotlin=scan.nextLine().toInt()
    var arr = scan.nextLine().split(" ").map{ it.trim().toInt() }.toTypedArray()
    var max = arr.max()
    var m = max
    for(x in arr)
    {
        if(x==max)
            break
        if(x< m!!)
            m=x
    }
    println(max!! - m!!)
}
