import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    var min = 0
    var max = 0
    for (i in 1..n) {
      val t = sc.nextInt()
      min = Math.min(t,min)
      max = Math.max(t,max)
    }
    println(max-min)
}
