let i = require('fs').readFileSync('/dev/stdin', 'utf8').split('\n').map((e) => e-0).slice(0, -1) let a = i.slice(2).sort((a,b) => a-b) console.log(a[i[0]-1] - a[0])