#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def insertSort(A, n, g):
    count = 0
    for i in range(g, n):
        v = A[i]
        x = i - g
        while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
        A[x+g] = v
    return count

def shellSort(A, n):
    # 3h+1(... 121, 40, 13, 4, 1) is a good value for G[]
    G = list()
    h = 1
    count = 0
    while h <= n:
        G.append(h)
        h = h*3 + 1
    G = G[::-1] # Reverse
    m = len(G)
    for g in G:
        count += insertSort(A, n, g)

    print(m)
    print(' '.join(map(str, G)))
    print(count)
    for a in A:
        print(a)

n = int(sys.stdin.readline())
A = list()
for i in range(n):
    A.append(int(sys.stdin.readline()))

shellSort(A, n)
 import sys sys def insertSort(A, n, g):
    count = 0
    for i in range(g, n):
        v = A[i]
        x = i - g
        while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
        A[x+g] = v
    return count insertSort count = 0 count 0 for i in range(g, n):
        v = A[i]
        x = i - g
        while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
        A[x+g] = v
     i range(g, n) range g n v = A[i] v A[i] A i x = i - g x i - g i g while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
         x >= 0 and A[x] > v x >= 0 x 0 A[x] > v A[x] A x v A[x+g] = A[x] A[x+g] A x+g x g A[x] A x x = x - g x x - g x g count += 1 count 1 A[x+g] = v A[x+g] A x+g x g v return count count A A n n g g def shellSort(A, n):
    # 3h+1(... 121, 40, 13, 4, 1) is a good value for G[]
    G = list()
    h = 1
    count = 0
    while h <= n:
        G.append(h)
        h = h*3 + 1
    G = G[::-1] # Reverse
    m = len(G)
    for g in G:
        count += insertSort(A, n, g)

    print(m)
    print(' '.join(map(str, G)))
    print(count)
    for a in A:
        print(a) shellSort G = list() G list() list h = 1 h 1 count = 0 count 0 while h <= n:
        G.append(h)
        h = h*3 + 1
     h <= n h n G.append(h) G.append G append h h = h*3 + 1 h h*3 + 1 h*3 h 3 1 G = G[::-1] G G[::-1] G ::-1 -1 m = len(G) m len(G) len G for g in G:
        count += insertSort(A, n, g)

     g G count += insertSort(A, n, g) count insertSort(A, n, g) insertSort A n g print(m) print m print(' '.join(map(str, G))) print ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G print(count) print count for a in A:
        print(a) a A print(a) print a A A n n n = int(sys.stdin.readline()) n int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline A = list() A list() list for i in range(n):
    A.append(int(sys.stdin.readline())) i range(n) range n A.append(int(sys.stdin.readline())) A.append A append int(sys.stdin.readline()) int sys.stdin.readline() sys.stdin.readline sys.stdin sys stdin readline shellSort(A, n) shellSort A n A = list() list() A def shellSort(A, n):
    # 3h+1(... 121, 40, 13, 4, 1) is a good value for G[]
    G = list()
    h = 1
    count = 0
    while h <= n:
        G.append(h)
        h = h*3 + 1
    G = G[::-1] # Reverse
    m = len(G)
    for g in G:
        count += insertSort(A, n, g)

    print(m)
    print(' '.join(map(str, G)))
    print(count)
    for a in A:
        print(a) def shellSort(A, n):
    # 3h+1(... 121, 40, 13, 4, 1) is a good value for G[]
    G = list()
    h = 1
    count = 0
    while h <= n:
        G.append(h)
        h = h*3 + 1
    G = G[::-1] # Reverse
    m = len(G)
    for g in G:
        count += insertSort(A, n, g)

    print(m)
    print(' '.join(map(str, G)))
    print(count)
    for a in A:
        print(a) shellSort n = int(sys.stdin.readline()) int(sys.stdin.readline()) n def insertSort(A, n, g):
    count = 0
    for i in range(g, n):
        v = A[i]
        x = i - g
        while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
        A[x+g] = v
    return count def insertSort(A, n, g):
    count = 0
    for i in range(g, n):
        v = A[i]
        x = i - g
        while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
        A[x+g] = v
    return count insertSort
#!/usr/bin/python3
# -*- coding: utf-8 -*-

import sys

def insertSort(A, n, g):
    count = 0
    for i in range(g, n):
        v = A[i]
        x = i - g
        while x >= 0 and A[x] > v:
            A[x+g] = A[x]
            x = x - g
            count += 1
        A[x+g] = v
    return count

def shellSort(A, n):
    # 3h+1(... 121, 40, 13, 4, 1) is a good value for G[]
    G = list()
    h = 1
    count = 0
    while h <= n:
        G.append(h)
        h = h*3 + 1
    G = G[::-1] # Reverse
    m = len(G)
    for g in G:
        count += insertSort(A, n, g)

    print(m)
    print(' '.join(map(str, G)))
    print(count)
    for a in A:
        print(a)

n = int(sys.stdin.readline())
A = list()
for i in range(n):
    A.append(int(sys.stdin.readline()))

shellSort(A, n)

