const Main = (input) => {
  const ar = input[1].split(' ');
  let mx = 1;
  let mn = 10 ** 9;
  for (let v of ar) {
    mx = v > mx ? v : mx;
    mn = v < mn ? v : mn;
  }
  console.log(mx - mn);
}

// 標準入力を受け取るおまじない
Main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'));
