function Main(input) {
  input = input.split("\n");
  var arr = input[1].split(' ');
  var newArr = arr.map(value => +value );

  console.log(Math.max.apply(null, newArr) - Math.min.apply(null, newArr));
}

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