'use strict';
const inputRaw = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
const INPUT_LIST_LENGTH_INDEX = 0;
const INPUT_LIST_INDEX = 1;
const INPUT_LIST_DELIMITER = " ";
const inputListLength = parseInt(inputRaw[INPUT_LIST_LENGTH_INDEX]);
const inputList = inputRaw[INPUT_LIST_INDEX].split(INPUT_LIST_DELIMITER);

const process = (inputList, inputListLength) => {
  let min = inputList[0];
  let max = inputList[0];

  for (let i=0;i<inputListLength; i++) {
    const current = parseInt(inputList[i]);

    if (current > max) {
      max = current;
    }
    if (current < min) {
      min = current;
    }
  }

  return max - min;
}

console.log(process(inputList, inputListLength));