#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int INF = 1e9;

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

void shell_sort(vector<int>& A, int n, int& cnt)
{
  vector<int> G;
  int h = 1;
  G.push_back(h);
  int upper = n / 2;
  // if (n >= 1000) { upper = n / 9; }
  // else if (n >= 100) { upper = n / 7; }
  for (int i = 3 * h + 1; i < upper; i = 3 * i + 1) {
    G.push_back(i);
  }
  reverse(G.begin(), G.end());
  int m = G.size();
  fprintf(stdout, "%d\n", m);
  for (int i = 0; i < m; ++i) {
    if (i) { fprintf(stdout, " "); }
    fprintf(stdout, "%d", G[i]);
  }
  fprintf(stdout, "\n");
  for (int i = 0; i < m; ++i) {
    insertion_sort(A, n, G[i], cnt);
  }
}

int main()
{
  int n = 0;
  fscanf(stdin, "%d", &n);
  vector<int> A(n);
  for (int i = 0; i < n; ++i) {
    fscanf(stdin, "%d", &A[i]);
  }
  int cnt = 0;
  shell_sort(A, n, cnt);
  fprintf(stdout, "%d\n", cnt);
  for (int i = 0; i < n; ++i) {
    fprintf(stdout, "%d\n", A[i]);
  }
  return 0;
}
#include <iostream>
#include <vector>

template<typename T>
void print_ary(std::vector<T> ary, char delim = '\n') {
    for(int i = 0; i < ary.size()-1; i++) {
        std::cout << ary[i] << delim;
    }
    std::cout << ary[ary.size()-1];
}


template<typename T>
void insertion_sort(std::vector<T>&& ary) {
    for (int i = 1; i < ary.size(); i++) {
        int target = ary[i];
        int j = i - 1;
        while(j >= 0 &&  ary[j] > target) {
            ary[j+1] = ary[j];
            j--;
        }
        ary[j+1] = target;
        print_ary(ary, ' ');
        std::cout << std::endl;
    }
}

template<typename T>
void bubble_sort(std::vector<T> && ary) {
    int n = ary.size();
    bool flag = true;
    int counter = 0;
    while (flag) {
        flag = false;
        for (int j = n - 1; j > 0; j--) {
            if (ary[j] < ary[j - 1]) {
                std::swap(ary[j], ary[j - 1]);
                flag = true;
                counter++;
            }
        }
    }
    print_ary(ary, ' ');
    std::cout << std::endl << counter << std::endl;;
}

template<typename T>
void selection_sort(std::vector<T>&& ary){
    int counter = 0;
    for (int i = 0; i < ary.size(); i++) {
        int min_index = i;
        for(int j = i + 1; j < ary.size(); j++) {
            if (ary[min_index] > ary[j]) {
                min_index = j;
            }
        }
        if(i != min_index) {
            std::swap(ary[i], ary[min_index]);
            counter++;
        }
    }
    print_ary(ary, ' ');
    std::cout << std::endl << counter << std::endl;;
}

template<typename T>
void insertion_sort(std::vector<T>&& ary, int g, int& cnt) {
    int n = ary.size();
    for (int i = g; i < n; i++) {
        int target = ary[i];
        int j = i - g;
        while(j >= 0 && ary[j] > target) {
            ary[j + g] = ary[j];
            cnt++;
            j -= g;
        }
        ary[j + g] = target;
    }
}

template<typename T>
void shell_sort(std::vector<T>&& ary){
    int cnt = 0;
    std::vector<int> G;
    for(int h = 1; ; ){
        if(h > ary.size())
            break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    std::cout << G.size() << std::endl;
    for(int i = G.size() - 1; i >= 0; i--) {
        insertion_sort(std::move(ary), G[i], cnt);
        std::cout << G[i];
        if (i != 0) {
            std::cout << " ";
        }else{
            std::cout << std::endl;
        }
    }
    std::cout << cnt << std::endl;
    print_ary(ary);
}


int main(int argc, char const* argv[])
{
    int n;
    std::cin >> n;
    std::vector<int> ary(n);
    for (auto &i: ary) {
        std::cin >> i;
    }
    shell_sort(std::move(ary));
    return 0;
}