import std.stdio, std.string, std.array, std.conv;

long cnt;
int[] y;

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

void shellSort(int n, int[] x) {
    int h = 1;
    while (true) {
        if (h > n) break;
        y ~= h;
        h = 3 * h + 1;
    }
    foreach_reverse (z; y) {
        insertionSort(n, z, x);
    }
}

void main() {
    int n = readln.chomp.to!int;
    int[] a = new int[n];
    foreach (i; 0 .. n) {
        a[i] = readln.chomp.to!int;
    }
    cnt = 0;
    shellSort(n, a);
    y.length.writeln;
    foreach_reverse (i, z; y) {
        z.write;
        if (i) " ".write;
        else writeln;
    }
    cnt.writeln;
    foreach (i, x; a) {
        x.writeln;
    }
}
