#!/usr/bin/env perl use strict; use warnings; my $n = <>; chomp$n; my @vs = split/ /, <>; chomp$vs[$n-1]; for (my $i = 1; $i < 2 * $n - 3; $i++) { my $pmax = ($i, $n - 1)[$i > $n - 1]; for (my $p = 0; $p < $pmax; $p++) { my $q = $i - $p; if ($p < $q && $q <= $n - 1 && $vs[$p] > $vs[$q]) { ($vs[$q], $vs[$p]) = ($vs[$p], $vs[$q]); } } } print join(' ', @vs); print "\n";