import math

def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

def shellSort(A,n):
    global cnt
    cnt = 0
    m = int(math.log(n))
    if m < 1:
        m = 1
    G = []
    for i in range(0,m):
        if i == 0:
            G.append(1)
        else:
            G.append(G[i-1]*3+1)
    G.sort(reverse=True)
    
    for i in range(0,m):
        insertionSort(A,n,G[i])
    print(m)
    for i in range(m):
        if i == m-1:
            print(G[i])
        else:
            print(G[i],end=" ")
    print(cnt)
    for i in range(n):
        print(A[i])

n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n) import math math def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v insertionSort global cnt for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v i range(g,n) range g n v = A[i] v A[i] A i j = i - g j i - g i g while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
         j >= 0 and A[j] > v j >= 0 j 0 A[j] > v A[j] A j v A[j+g] = A[j] A[j+g] A j+g j g A[j] A j j = j - g j j - g j g cnt += 1 cnt 1 A[j+g] = v A[j+g] A j+g j g v A A n n g g def shellSort(A,n):
    global cnt
    cnt = 0
    m = int(math.log(n))
    if m < 1:
        m = 1
    G = []
    for i in range(0,m):
        if i == 0:
            G.append(1)
        else:
            G.append(G[i-1]*3+1)
    G.sort(reverse=True)
    
    for i in range(0,m):
        insertionSort(A,n,G[i])
    print(m)
    for i in range(m):
        if i == m-1:
            print(G[i])
        else:
            print(G[i],end=" ")
    print(cnt)
    for i in range(n):
        print(A[i]) shellSort global cnt cnt = 0 cnt 0 m = int(math.log(n)) m int(math.log(n)) int math.log(n) math.log math log n if m < 1:
        m = 1
     m < 1 m 1 m = 1 m 1 G = [] G [] for i in range(0,m):
        if i == 0:
            G.append(1)
        else:
            G.append(G[i-1]*3+1)
     i range(0,m) range 0 m if i == 0:
            G.append(1)
        else:
            G.append(G[i-1]*3+1)
     i == 0 i 0 G.append(1) G.append G append 1 G.append(G[i-1]*3+1) G.append G append G[i-1]*3+1 G[i-1]*3 G[i-1] G i-1 i 1 3 1 G.sort(reverse=True) G.sort G sort reverse=True reverse True for i in range(0,m):
        insertionSort(A,n,G[i])
     i range(0,m) range 0 m insertionSort(A,n,G[i]) insertionSort A n G[i] G i print(m) print m for i in range(m):
        if i == m-1:
            print(G[i])
        else:
            print(G[i],end=" ")
     i range(m) range m if i == m-1:
            print(G[i])
        else:
            print(G[i],end=" ")
     i == m-1 i m-1 m 1 print(G[i]) print G[i] G i print(G[i],end=" ") print G[i] G i end=" " end " " print(cnt) print cnt for i in range(n):
        print(A[i]) i range(n) range n print(A[i]) print A[i] A i A A n n n = int(input()) n int(input()) int input() input A = [] A [] for i in range(n):
    A.append(int(input())) i range(n) range n A.append(int(input())) A.append A append int(input()) int input() input shellSort(A,n) shellSort A n def shellSort(A,n):
    global cnt
    cnt = 0
    m = int(math.log(n))
    if m < 1:
        m = 1
    G = []
    for i in range(0,m):
        if i == 0:
            G.append(1)
        else:
            G.append(G[i-1]*3+1)
    G.sort(reverse=True)
    
    for i in range(0,m):
        insertionSort(A,n,G[i])
    print(m)
    for i in range(m):
        if i == m-1:
            print(G[i])
        else:
            print(G[i],end=" ")
    print(cnt)
    for i in range(n):
        print(A[i]) def shellSort(A,n):
    global cnt
    cnt = 0
    m = int(math.log(n))
    if m < 1:
        m = 1
    G = []
    for i in range(0,m):
        if i == 0:
            G.append(1)
        else:
            G.append(G[i-1]*3+1)
    G.sort(reverse=True)
    
    for i in range(0,m):
        insertionSort(A,n,G[i])
    print(m)
    for i in range(m):
        if i == m-1:
            print(G[i])
        else:
            print(G[i],end=" ")
    print(cnt)
    for i in range(n):
        print(A[i]) shellSort A = [] [] A def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v insertionSort n = int(input()) int(input()) n
import math

def insertionSort(A,n,g):
    global cnt
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v

def shellSort(A,n):
    global cnt
    cnt = 0
    m = int(math.log(n))
    if m < 1:
        m = 1
    G = []
    for i in range(0,m):
        if i == 0:
            G.append(1)
        else:
            G.append(G[i-1]*3+1)
    G.sort(reverse=True)
    
    for i in range(0,m):
        insertionSort(A,n,G[i])
    print(m)
    for i in range(m):
        if i == m-1:
            print(G[i])
        else:
            print(G[i],end=" ")
    print(cnt)
    for i in range(n):
        print(A[i])

n = int(input())
A = []
for i in range(n):
    A.append(int(input()))
shellSort(A,n)