#include <iostream>
#include <memory>
#include <cmath>

constexpr int max_size()
{
    return static_cast<int>(1e+6);
}

int insert(int* a, const int i, const int gear)
{
    if (i < gear) {
        return 0;
    }

    if (a[i - gear] <= a[i]) {
        return 0;
    }

    std::swap(a[i - gear], a[i]);
    return 1 + insert(a, i - gear, gear);
}

int insertion_sort(int* arr, const int n, const int gear)
{
    int insert_count = 0;
    for (int i = 0; i < n; i += gear) {
        insert_count += insert(arr, i, gear);
    }
    return insert_count;
}

int pow(const int a, const int x) {
    return x == 0 ? 1 : a * pow(a, x - 1);
}

void print(int* arr, const int n, const int i, char const delim) {
    if (i == n - 1) {
        std::cout << arr[i];
        return;
    }

    std::cout << arr[i] << delim;
    print(arr, n, i + 1, delim);
}

void print(int* arr, const int n, char const delim) {
    int i = 0;
    for (; i < n - 1; ++i) {
        std::cout << arr[i] << delim;
    }
    std::cout << arr[i];
}

void shell_sort(int* arr, const int n) {
    static const double log3 = std::log(3);
    const int gear_index = static_cast<int>(std::log(2 * n + 1) / log3 - 1);
    int gear = (pow(3, gear_index + 1) - 1) >> 1;

    int gear_cache[100];
    int cache_idx = 0;
    int insert_count = 0;

    for (; gear > 0; gear = (gear - 1) / 3) {
        gear_cache[cache_idx] = gear;
        for (int i = 0; i < gear; ++i) {
            insert_count += insertion_sort(arr + i, n - i, gear);
        }
        ++cache_idx;
    }

    std::cout << cache_idx << std::endl;
    print(gear_cache, cache_idx, ' ');
    std::cout << std::endl;
    std::cout << insert_count << std::endl;

    return;
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int n;
    std::cin >> n;

    constexpr int N = max_size();
    const auto r = std::make_unique<int[]>(N);
    for (int i = 0; i < n; ++i) {
        std::cin >> r[i];
    }

    shell_sort(r.get(), n);
    print(r.get(), n, '\n');
    std::cout << std::endl;

    return 0;
}
#include <iostream>
using namespace std;
int main(void){
  int cnt=0,m=0,n,a[1000000],g[100]={0};
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i];
  g[0]=1;
  while(g[m]<n){
    g[m+1]=3*g[m]+1;
    m++;
  }
  if(n==1)
    m=1;
  for(int i=m-1;i>=0;i--){
    for(int k=g[i];k<n;k++){
      int v=a[k];
      int j=k-g[i];
      while(j>=0&&a[j]>v){
	a[j+g[i]]=a[j];
	j=j-g[i];
	cnt++;
      }
      a[j+g[i]]=v;
    }
  }
  cout<<m<<endl;
  for(int i=m-1;i>0;i--)
    cout<<g[i]<<" ";
  cout<<g[0]<<endl;
  cout<<cnt<<endl;
  for(int i=0;i<n;i++)
    cout<<a[i]<<endl;
  return 0;
}