function Main(input){
  input = input.split("\n");
	tmp = input[1].split(" ");
  tmp = tmp.map((a)=>Number(a));
  tmp.sort((a,b)=>a>b);
  console.log(tmp[tmp.length-1]-tmp[0]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));