function solve(N: number, K: number, n: number[]): number { let min = n[0]; let max = n[0]; for (let i = 1; i < N; i++) { if (n[i] < min) min = n[i]; if (n[i] > max) max = n[i]; } return max - min; } import * as fs from 'node:fs'; const input = fs.readFileSync('/dev/stdin', 'utf8').trim().split(/\s+/); let index = 0; const N = parseInt(input[index++]); const K = parseInt(input[index++]); const n: number[] = []; for (let i = 0; i < N; i++) { n.push(parseInt(input[index++])); } console.log(solve(N, K, n));