import strutils, sequtils let N, A = stdin.readLine.split.map parseInt n = N[0] var a = A for i in 1 ..< 2 * n - 3: for p in countdown(n - 1, 0): let q = i - p if q >= 0 and q <= n - 1 and p != q: if a[p] > a[q]: swap(a[p], a[q]) echo a.join(" ")