function main(s) {
	s = s.split("\n")[1].split(" ").map(x => Number(x));
	var x = 1000;
	var y = 0;
	for (var i = 0; i < s.length; i++) {
		if (s[i] < x) {x = s[i];}
		if (s[i] > y) {y = s[i];}
	}
	console.log(y-x);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));

