import java.util.Scanner

fun main(args: Array<String>) {
  val cin = Scanner(System.`in`)
  val n = cin.nextInt()

  var maxA = -1
  var minA = 1000000010
  for (i in 0 until n) {
    val a = cin.nextInt()
    maxA = Math.max(maxA, a)
    minA = Math.min(minA, a)
  }

  println(maxA - minA)

  cin.close()
}