#include<stdio.h>

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

  return cnt;
}

void shellSort(int A[], int n) {
  int im, m = 1, v = 1, G[100], sum = 0;
  for ( im = 0; v <= n; im++ ) {
    G[im] = v;
    m *= 3;
    v += m;
  }

  printf("%d\n", im);
  for ( int i = im - 1; i >= 0; i-- ) {
    if ( i != (im - 1) ) printf(" ");
    printf("%d", G[i]);
    sum += insertionSort(A, n, G[i]);
  }

  printf("\n%d\n", sum);
  for ( int i = 0; i < n; i++ ) {
    printf("%d\n", A[i]);
  }
}

int main() {
  int n, A[1000000];
  scanf("%d", &n);

  for ( int i = 0; i < n; i++ ) scanf("%d", &A[i]);

  shellSort(A, n);

  return 0;
}


#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int cnt;

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

void shellSort(vector<int> &mat){
    vector<int>g;
    cnt = 0;
    for(int h=1;h<=mat.size();h=3*h+1)g.push_back(h);
    reverse(g.begin(),g.end());
    int m = g.size();
    cout << m << endl;
    for(int i=0;i<g.size();i++){
        if(i<g.size()-1) cout << g[i] << " ";
        else cout << g[i] << endl;
    }
    for(int i=0;i<m;i++)insertionSort(mat,g[i]);
}

int main(){
    vector<int> mat;
    int n,x;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> x;
        mat.push_back(x);
    }
    shellSort(mat);
    cout << cnt << endl;
    for(int i=0;i<n;i++) cout << mat[i] << endl;
    return 0;
}