'use strict'

const main = input => {
	const args = input.trim().split('\n')
	const n = parseInt(args[0], 10)
	const a = args[1].split(' ').map(Number)
	let min = 1000000001
	let max = 0

	for (let i = 0; i < n; i++) {
		min = Math.min(min, a[i])
		max = Math.max(max, a[i])
	}

	console.log(max - min)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
