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, j;
    for (i = 0; i < len; i++) {
        for (j = 0; j < len; j++) {
            if (i === j) continue;
            var diff = Math.abs(nums[i] - nums[j]);
            if (max < diff) {
                max = diff;
            }
        }
    }
    console.log(max);
}

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