#include<iostream>
#include<cmath>
using namespace std;
#include<vector>

#define ArrayNum 100

vector<int> g;

int insertionSort(int a[],int n,int g){
  int i,j,cnt=0,v;

  for(i=g;i<n;i++){
    v= a[i];
    j=i-g;
    while(j>=0 && a[j]>v){
      a[j+g]=a[j];
      j=j-g;
      cnt++;
    }
    a[j+g]=v;
  }
  return cnt;
}

void shellSort(int a[], int n){
  int i,cnt=0,m;
  
  for(int h=1;;){
    if(h>n)
      break;
  g.push_back(h);
  h=3*h+1;
  }
  m=g.size();
  for(i=m-1;i>=0;i--)
    cnt=cnt+insertionSort(a,n,g[i]);

  for(i=0;i<m-1;i++)
    cout << g[i] << " ";
  cout << c[m-1] << "\n";
  for(i=0;i<n;i++)
    cout << a[i] << "\n";
  cout << cnt << "\n";
}

int main(void){
  int i,n,a[ArrayNum];
  cin >> n;
  for(i=0;i<n;i++)
    cin >> a[i];
  shellSort(a,n);

}

