import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    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 -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i]) import sys sys def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print() print_A for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
     i range(len(A)) range len(A) len A sys.stdout.write(str(A[i])) sys.stdout.write sys.stdout sys stdout write str(A[i]) str A[i] A i if i!= len(A) -1:
            sys.stdout.write(' ')
     i!= len(A) -1 i len(A) -1 len(A) len A 1 sys.stdout.write(' ') sys.stdout.write sys.stdout sys stdout write ' ' print() print A A def insertionSort(A,n,g):
    cnt = 0
    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 -= g
            cnt +=1
        A[j + g] = v
    return cnt insertionSort cnt = 0 cnt 0 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 -= 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 -= 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 -= g j g cnt +=1 cnt 1 A[j + g] = v A[j + g] A j + g j g v return cnt cnt A A n n g g def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
         shellSort cnt = 0 cnt 0 for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
     i range(len(G)) range len(G) len G cnt += insertionSort(A,n,G[i]) cnt insertionSort(A,n,G[i]) insertionSort A n G[i] G i return cnt cnt A A n n G G def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G)) get_gap G = [] G [] h = 1 h 1 cnt = 1 cnt 1 while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
     h <= n h n G.append(h) G.append G append h h = 3*h + 1 h 3*h + 1 3*h 3 h 1 cnt +=1 cnt 1 if len(G) == 0: G.append(1)
     len(G) == 0 len(G) len G 0 return list(reversed(G)) list(reversed(G)) list reversed(G) reversed G n n n = int(input()) n int(input()) int input() input A = [0] * n A [0] * n [0] 0 n for i in range(n):
    A[i] = int(input())
     i range(n) range n A[i] = int(input()) A[i] A i int(input()) int input() input G = get_gap(n) G get_gap(n) get_gap n m = len(G) m len(G) len G cnt = shellSort(A,n,G) cnt shellSort(A,n,G) shellSort A n G print(m) print m print_A(G) print_A G 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 def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print() def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print() print_A def insertionSort(A,n,g):
    cnt = 0
    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 -= g
            cnt +=1
        A[j + g] = v
    return cnt def insertionSort(A,n,g):
    cnt = 0
    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 -= g
            cnt +=1
        A[j + g] = v
    return cnt insertionSort G = get_gap(n) get_gap(n) G n = int(input()) int(input()) n m = len(G) len(G) m def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
         def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
         shellSort def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G)) def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G)) get_gap cnt = shellSort(A,n,G) shellSort(A,n,G) cnt A = [0] * n [0] * n A
import sys


def print_A(A):
    for i in range(len(A)):
        sys.stdout.write(str(A[i]))
        if i!= len(A) -1:
            sys.stdout.write(' ')
    print()


def insertionSort(A,n,g):
    cnt = 0
    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 -= g
            cnt +=1
        A[j + g] = v
    return cnt

def shellSort(A,n,G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertionSort(A,n,G[i])
    return cnt
        

def get_gap(n):
    G = []
    h = 1
    cnt = 1
    while h <= n:
        G.append(h)
        h = 3*h + 1
        cnt +=1
    if len(G) == 0: G.append(1)
    return list(reversed(G))


n = int(input())
A = [0] * n
for i in range(n):
    A[i] = int(input())
    
G = get_gap(n)
m = len(G)
cnt = shellSort(A,n,G)

print(m)
print_A(G)
print(cnt)
for i in range(n):
    print(A[i])
