function main(input) {
    var args = input.split("\n");
	var len = parseInt(args[0].split(" ")[0]);
	var cho = parseInt(args[0].split(" ")[1]);
	var count = 1;
	var high = 0;
	var low = 100000;
	
	while (count <= len) {
		if (parseInt(args[count]) > high) {
			high = parseInt(args[count]);
			
		} else if (parseInt(args[count]) < low) {
			low = parseInt(args[count]);
			
		}
		count++;
		
	}
	console.log("" + high - low);
	
}

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