function main(input) {
    var array = input.split('\n');
    var numbers = array[1].split(' ');

    console.log(Math.max.apply(null, numbers) - Math.min.apply(null, numbers));
}

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