function main(input) {
  const args = input.split('\n');
  const N = parseInt(args[0], 10);
  const ary = args[1].split(' ').map(n => parseInt(n, 10));
  
  const aryMax = (a, b) => {return Math.max(a, b);}
  const aryMin = (a, b) => {return Math.min(a, b);}
  let max = ary.reduce(aryMax);
  let min = ary.reduce(aryMin);
  
  console.log(max - min);
}

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