#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>

int cnt;
int l;
int A[1000000];
int n;
std::vector<int> G;

void insertionSort(int A[], int n, int g) {
	for (int i = g; i < n; i++) {
		int v = A[i];
		int j = i - g;
		while (j >= 0 && A[j] > v) {
			A[j + g] = A[j];
			j -= g;
			cnt++;
		}
		A[j + g] = v;
	}
}

void shellSort(int A[], int n) {
	for (int h=1; ; ) {
		if (h > n) {
			break;
		}
		G.push_back(h);
		h = 3*h + 1;
	}

	for (int i = G.size()-1; i >=0; i--) {
		insertionSort(A, n, G[i]);
	}
}

int main() {
	std::cin >> n;
	for (int i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}
	cnt = 0;

	shellSort(A, n);

	std::cout << G.size() << std::endl;

	for (int i = G.size() - 1; i >= 0; i--) {
		printf("%d", G[i]);
		if (i) printf(" ");
	}
	printf("\n");
	printf("%d\n", cnt);
	for (int i = 0; i < n; i++) {
		printf("%d\n", A[i]);
	}

	return 0;
}



#include <iostream>
#include <algorithm>
#include <string>
#define N 50
using namespace std;
struct data{
  string l;
  int p,a,b,c,d,e,f,s,m;
  double cal;
};
int main(){
  int n,i,j,time;
  struct data d[N];
  while(1){
    cin >> n;
    if(n==0) break;
    for(i=0;i<n;i++){
      cin >> d[i].l >> d[i].p >> d[i].a >> d[i].b >> d[i].c;
      cin >> d[i].d >> d[i].e >> d[i].f >> d[i].s >> d[i].m;
      time=(d[i].a+d[i].b+d[i].c+d[i].d+d[i].e);
      d[i].m--;
      time+=(d[i].d+d[i].e)*d[i].m;
      d[i].cal=((double)d[i].f*d[i].s*(d[i].m+1)-d[i].p)/time;
    }
    for(i=0;i<n;i++){
      for(j=1;j<n;j++){
	if(d[j].l<d[j-1].l) swap(d[j],d[j-1]);
      }
    }
    for(i=0;i<n;i++){
      for(j=1;j<n;j++){
	if(d[j].cal>d[j-1].cal) swap(d[j],d[j-1]);
      }
    }
    for(i=0;i<n;i++) cout << d[i].l << endl;
    cout << '#' << endl;
  }
  return 0;
}