'use strict'
let input = require("fs").readFileSync("/dev/stdin", "utf8");
let info = input.split('\n');
let nums = info[1].split(' ').map(x => x*1);
let max = Math.max(...nums);
let min = Math.min(...nums);

console.log(max - min);