function main (input) {
    const N = input.split('\n')[0];
    var a = input.split('\n')[1].split(' ')
                 .map(function(e){return Number(e);})
                 .sort(function(a,b){return a-b;});

    ans = a[N-1] - a[0];
    console.log(ans);
}

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