function main(input) {
  let inputs = input.split(/\n/);
  let args = inputs[1].split(/\s/);
  console.log(Math.max(...args) - Math.min(...args));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));