function Main(input) {
  input = input.split("\n");
  let num = input[1].split(' ');

  var length = input[0];
  for (let i = 1; i < length ; i++) {
    num[i] = Math.floor(Math.random()* 10^9);
  }
  
  var arr = num.sort(() => {
    return a - b;
  });
  
  console.log(arr[length] - arr[0]);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

