const fs = require("fs");

function Main(input){
  input = input.split("\n");
  var numArray = iniput[1].split(" ");
  var max = Math.max.apply(null, numArray);
  var min = Math.min.apply(null, numArray);
  console.log(Math.abs(max - min));
}
Main(fs.readFileSync("/dev/stdin", "utf8"));