import java.util.Scanner;

fun main(args: Array<String>) {
	val scanner = Scanner(System.`in`)
	val n = scanner.nextInt()
	var min = Integer.MAX_VALUE
	var max = 0
	repeat(n) {
		val a = scanner.nextInt()
		min = Math.min(min, a)
		max = Math.max(max, a)
	}
	println(max-min)
}