inp = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n')
N = inp.shift()
A = inp.shift().split(' ').map(x => x - 0)
min = Math.pow(10, 9)
max = 1
for (i=0; i<N; i++) {
    if (A[i] > max) {
        max = A[i]
    }
    if (A[i] < min) {
        min = A[i]
    }
}
console.log(max - min)