"use strict"

function main(input) {

    let ary = input.split('\n')
    let nums = ary[1].split(' ')
    nums = nums.map(x => +x)
    console.log(Math.max.apply(null, nums) - Math.min.apply(null, nums))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
