const data = require('fs') .readFileSync('/dev/stdin', 'utf-8'); const [N, K, ...n] = data .trim().split('\n').map(x => Number(x)); n.sort(); console.log(n[n.length - 1] - n[0]);