function arrInt(arr) { return arr.map(str => parseInt(str, 10)); } function Main(input) { const src = input.split("\n"); const n = parseInt(src[0]); const a = arrInt(src[1].split(" ")); for (let i = 1; i < 2 * n - 3; i++) { for (let p = 0; p < n - 1; p++) { let q = i - p; if (p < q && a[p] > a[q]) { [a[p], a[q]] = [a[q], a[p]]; } } } console.log(a.join(" ")); } Main(require("fs").readFileSync("/dev/stdin", "utf8"));