process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on('data', function(chunk){
    var lines = chunk.toString().split("\n");
    var N = parseInt(lines[0]);
    var a = lines[1];
    var A =a.split(" "); 
    
    var min = A[0];
    var max = A[0];
    
    
    for(i=0; i<N; i++){
        min = Math.min(min,A[i]);
    }

    for(i=0; i<N; i++){
        max = Math.max(max,A[i]);
    }

/*
    console.log(min);
    console.log(max);
*/
    var ans = max-min;  
    console.log(ans);
});