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