using namespace std;
int num[100] = { 0 };
int n;
void shellinsert(int dk){
int i, j;
int tmp;
for (i = dk ; i < n; i++){
if (num[i] < num[i - dk]){
tmp = num[i];
for (j = i - dk; j>=0 && tmp < num[j]; j -= dk){
num[j + dk] = num[j];
}
num[j + dk] = tmp;
}
}
}
void shellsort(int t,int d[]){
int i;
for (i = 0; i <t; ++i){
shellinsert(d[i]);
}
}
int main(){
int d[10] = { 0 };
int i;
while (cin >> n){
int a = n;
for (i = 0; i < n; i++){
cin >> num[i];
}
i = 0;
while (a > 1){
a = (int)ceil(a / 2.0);
d[i++] = a;
}
d[i] = 1;
i++;
shellsort(i,d);
for (i = 0; i < n; i++){
cout << num[i] << " ";
}
cout << endl;
}
return 0;
}