function main(input) {
    var n, a = [], tmp, size, sum = 0, i;
    n = parseInt(input[0], 10);
    tmp = input[1].split(" ");
    size = tmp.length;
    for (i = 0; i < size; i++) {
        a.push(parseInt(tmp[i], 10));
    }
    a.sort(function (self, other) {
        if (self < other) {
            return -1;
        } else if (self > other) {
            return 1;
        } else {
            return 0;
        }
    });
    for (i = 0; i < n - 1; i++) {
        sum += a[i + 1] - a[i];
    }

    console.log(sum);
}

main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));