def InsertionSort(a, N, Gap):
    c = 0
    for i in range(Gap, N):
        v = a[i]
        j = i - Gap
        while j >= 0 and a[j] > v:
            a[j+Gap] = a[j]
            j -= Gap
            c += 1
        a[j+Gap] = v
    return a, c

def ShellSort(a, N):
    cnt = 0
    G = [1]
    for i in range(1, N):
        if (3*G[i-1]+1) <= N:
            G.append(3*G[i-1]+1)
        else:
            break
            
    for g in G[::-1]:
        a, c = InsertionSort(a, N, g)
        cnt += c
    return a, cnt, G


N = int(input())
A = []
cnt = 0

for _ in range(N):
    A.append(int(input()))


sorted_A, cnt, G = ShellSort(A, N)
print(len(G))
print(*G[::-1])
print(cnt)
print(*sorted_A, sep="\n") def InsertionSort(a, N, Gap):
    c = 0
    for i in range(Gap, N):
        v = a[i]
        j = i - Gap
        while j >= 0 and a[j] > v:
            a[j+Gap] = a[j]
            j -= Gap
            c += 1
        a[j+Gap] = v
    return a, c InsertionSort c = 0 c 0 for i in range(Gap, N):
        v = a[i]
        j = i - Gap
        while j >= 0 and a[j] > v:
            a[j+Gap] = a[j]
            j -= Gap
            c += 1
        a[j+Gap] = v
     i range(Gap, N) range Gap N v = a[i] v a[i] a i j = i - Gap j i - Gap i Gap while j >= 0 and a[j] > v:
            a[j+Gap] = a[j]
            j -= Gap
            c += 1
         j >= 0 and a[j] > v j >= 0 j 0 a[j] > v a[j] a j v a[j+Gap] = a[j] a[j+Gap] a j+Gap j Gap a[j] a j j -= Gap j Gap c += 1 c 1 a[j+Gap] = v a[j+Gap] a j+Gap j Gap v return a, c return a, c a c a a N N Gap Gap def ShellSort(a, N):
    cnt = 0
    G = [1]
    for i in range(1, N):
        if (3*G[i-1]+1) <= N:
            G.append(3*G[i-1]+1)
        else:
            break
            
    for g in G[::-1]:
        a, c = InsertionSort(a, N, g)
        cnt += c
    return a, cnt, G ShellSort cnt = 0 cnt 0 G = [1] G [1] 1 for i in range(1, N):
        if (3*G[i-1]+1) <= N:
            G.append(3*G[i-1]+1)
        else:
            break
            
     i range(1, N) range 1 N if (3*G[i-1]+1) <= N:
            G.append(3*G[i-1]+1)
        else:
            break
            
     (3*G[i-1]+1) <= N 3*G[i-1]+1 3*G[i-1] 3 G[i-1] G i-1 i 1 1 N G.append(3*G[i-1]+1) G.append G append 3*G[i-1]+1 3*G[i-1] 3 G[i-1] G i-1 i 1 1 break for g in G[::-1]:
        a, c = InsertionSort(a, N, g)
        cnt += c
     g G[::-1] G ::-1 -1 a, c = InsertionSort(a, N, g) a InsertionSort(a, N, g) InsertionSort a N g c cnt += c cnt c return a, cnt, G return a, cnt, G a cnt G a a N N N = int(input()) N int(input()) int input() input A = [] A [] cnt = 0 cnt 0 for _ in range(N):
    A.append(int(input())) _ range(N) range N A.append(int(input())) A.append A append int(input()) int input() input sorted_A, cnt, G = ShellSort(A, N) sorted_A ShellSort(A, N) ShellSort A N cnt G print(len(G)) print len(G) len G print(*G[::-1]) print *G[::-1] G[::-1] G ::-1 -1 print(cnt) print cnt print(*sorted_A, sep="\n") print *sorted_A sorted_A sep="\n" sep "\n" G = ShellSort(A, N) ShellSort(A, N) G N = int(input()) int(input()) N cnt = 0 0 cnt sorted_A, cnt, G = ShellSort(A, N) ShellSort(A, N) sorted_A def ShellSort(a, N):
    cnt = 0
    G = [1]
    for i in range(1, N):
        if (3*G[i-1]+1) <= N:
            G.append(3*G[i-1]+1)
        else:
            break
            
    for g in G[::-1]:
        a, c = InsertionSort(a, N, g)
        cnt += c
    return a, cnt, G def ShellSort(a, N):
    cnt = 0
    G = [1]
    for i in range(1, N):
        if (3*G[i-1]+1) <= N:
            G.append(3*G[i-1]+1)
        else:
            break
            
    for g in G[::-1]:
        a, c = InsertionSort(a, N, g)
        cnt += c
    return a, cnt, G ShellSort cnt, G = ShellSort(A, N) ShellSort(A, N) cnt def InsertionSort(a, N, Gap):
    c = 0
    for i in range(Gap, N):
        v = a[i]
        j = i - Gap
        while j >= 0 and a[j] > v:
            a[j+Gap] = a[j]
            j -= Gap
            c += 1
        a[j+Gap] = v
    return a, c def InsertionSort(a, N, Gap):
    c = 0
    for i in range(Gap, N):
        v = a[i]
        j = i - Gap
        while j >= 0 and a[j] > v:
            a[j+Gap] = a[j]
            j -= Gap
            c += 1
        a[j+Gap] = v
    return a, c InsertionSort A = [] [] A
def InsertionSort(a, N, Gap):
    c = 0
    for i in range(Gap, N):
        v = a[i]
        j = i - Gap
        while j >= 0 and a[j] > v:
            a[j+Gap] = a[j]
            j -= Gap
            c += 1
        a[j+Gap] = v
    return a, c

def ShellSort(a, N):
    cnt = 0
    G = [1]
    for i in range(1, N):
        if (3*G[i-1]+1) <= N:
            G.append(3*G[i-1]+1)
        else:
            break
            
    for g in G[::-1]:
        a, c = InsertionSort(a, N, g)
        cnt += c
    return a, cnt, G


N = int(input())
A = []
cnt = 0

for _ in range(N):
    A.append(int(input()))


sorted_A, cnt, G = ShellSort(A, N)
print(len(G))
print(*G[::-1])
print(cnt)
print(*sorted_A, sep="\n")