let lines = [] const reader = require('readline').createInterface({ input: process.stdin, output: process.stdout }) reader.on('line', (line) => { lines.push(line) }) reader.on('close', () => { let points = lines[1].split(' ') let sorted = points.sort((a, b) => { if (a < b) return -1 if (a > b) return 1 return 0 }) var minDistance = Infinity for (var i = 1; i < sorted.length; i ++) { Math.abs(sorted[i] - sorted[i - 1]) < minDistance ? minDistance = sorted[i] - sorted[i - 1] : false } console.log(minDistance) console.log(Math.abs(sorted[0] - sorted[sorted.length - 1])) })