function Main(inp) {
    var input = inp.split("\n");
    var n = Number(input[0]);
    var nums = input[1].split(' ').map(function(n) {return Number(n);});
    var i, len = nums.length, max = 0, min = Number.MAX_VALUE;
    nums.forEach(function(n) {
        if (n > max) {
            max = n;
        }
        if (n < min) {
            min = n;
        }
    })
    console.log(max - min);
}

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