import java.util.Scanner;
/**
* @author 杨川
*
*/
public class Sort {
public static void main(String[] args) {
int a[] = input();
insertSort(a);
shellSort(a);
selectSort(a);
fastSort(a,0,a.length-1);
for (int k = 0; k < a.length; k++) {
System.out.print(a[k] + " ");
}
}
static void fastSort(int[]a,int s,int t){
int i=s;
int j=t;
if (s<t) {
int last=a[s];
while(i!=j){
while(j>i&&a[j]>=last){
j--;
}
a[i]=a[j];
while(i<j&&a[i]<=last){
i++;
}
a[j]=a[i];
}
a[i]=last;
fastSort(a,s,i-1);
fastSort(a, i+1, t);
}
}
static int[] selectSort(int a[]){
for (int i = 0; i < a.length-1; i++) {
int min=i;
for (int j = i+1; j < a.length; j++) {
if (a[j]<a[min]) {
min=j;
}
}
if (min!=i) {
int temp=a[i];
a[i]=a[min];
a[min]=temp;
}
}
for (int i = 0; i < a.length; i++) {
System.out.print(a[i] + " ");
}
return a;
}
static int[] insertSort(int a[]) {
for (int i = 1; i < a.length; i++) {
int temp = a[i];
int j = i - 1;
while (j >= 0 && temp < a[j]) { // 比前面的小的话元素逐个往后移,直到找到不小于它的位置(正确位置)
a[j + 1] = a[j];
j--;
}
a[j + 1] = temp;
}
for (int i = 0; i < a.length; i++) {
System.out.print(a[i] + " ");
}
return a;
}
static int[] shellSort(int a[]) {
int gap = a.length/2;
while (gap > 0) {
// int gap=5;
for (int i = gap; i < a.length; i++) {
int temp = a[i];
int j = i - gap;
while (j >= 0 && temp < a[j]) {
a[j + gap] = a[j];
j -= gap;
}
a[j + gap] = temp;
}
gap = gap/2;
}
for (int i = 0; i < a.length; i++) {
System.out.print(a[i] + " ");
}
return a;
}
static int[] input() {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int a[] = new int[n];
for (int i = 0; i < n; i++) {
a[i] = scanner.nextInt();
}
return a;
}
}