var input = require('fs').readFileSync('/dev/stdin', 'utf8')
input = input.trim().split('\n').map(Number);
console.log(input)

var n = input[0]
var r = input.slice(1)
var min = Math.min.apply(null, r);
var max = Math.max.apply(null, r.slice(r.indexOf(min)))

console.log(max - min)