"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = ~~arg[0];
    const a = arg[1].split(" ").map(n=>~~n).sort((a,b)=>a-b);
    
    console.log(Math.max(...a) - Math.min(...a));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));