function main(input){
    input = input.split("\n");
    temp = input[1].split(" ");
    len = input[0];
    min = 1001;
    max = 0;
    for(var i = 0; i < len; i+=1){
        if(min > temp[i]){
            min = temp[i];
        }
        if(max < temp[i]){
            max = temp[i];
        }
    }
    console.log(max - min);
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));