function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var num = parseInt(line[0]);
    var max = 0;
    var min = 10000;
    var data = input[1].split(" ");

    for(var i = 0;i<num;i++){
        data[i] = parseInt(data[i]);        
    }
    
    for(var i = 0;i<num;i++){
        if(max<data[i]){
            max = data[i];
        }
        
        if(min>data[i]){
            min = data[i];
        }
    }
    
    
    console.log(max-min);

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