function Main(input) {
    input = input.split("\n");
    var house_num = Number(input[0]);
    var houses = input[1].split(' ');
    var smallest = houses[0];
    var largest = 0;
    for(var i = 0; i < houses.length; i++){
        if(houses[i] > largest){
            largest = houses[i];
        }
        if(houses[i] < smallest){
            smallest = houses[i];
        }
    }
    var answer = largest - smallest;
    console.log(answer);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));