const input = require("fs").readFileSync("/dev/stdin", "utf8")

const [num, array] = input.split('\n')
const newArray = array.split(' ').map((num) => +num)
const distance = Math.max(...newArray) - Math.min(...newArray)
console.log(distance)