function Main(input) {
	input = input.split("\n")[1].split(" ");
    var max = 0, min = Infinity;
    for (val in input) {
        max = Math.max(input[val], max);
        min = Math.min(input[val], min);
    }
	//出力
	console.log(max - min);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));