function Main(input) {
    var input = input.split('\n');
    var nidan = input[1].split(' ').map(n => parseInt(n, 10)).sort((a, b) => a < b ? -1 : 1);
    console.log(nidan[nidan.length-1] - nidan[0]);

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