function main(input){
	var arr = input.split('\n')[1].split(' ').map(e=>Number(e)).sort();
	console.log((arr[arr.length - 1] - arr[0]) + '');
}

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