function Main(input) {
	input = input.trim();
  var len = parseInt(input.split("\n")[0]);
  var list = input.split("\n")[1].split(" ").map((a)=>Number(a));
  list.sort(function(a,b){
    return a - b;
  });
  console.log(list[len - 1] - list[0]);
}

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