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

def shellSort(A,n):
    count = 0
    m = 0
    G = []
    while (3**(m+1)-1)//2 <= n:
        m += 1
        G.append((3**m-1)//2)
    for i in range(m):
        count = insertionSort(A,n,G[-1-i],count)
    return m,G,count

import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

m,G,count = shellSort(A,N)

print(m)
print(*G[::-1])
print(count)
print('\n'.join(map(str,A))) def insertionSort(A,n,g,count):
    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
            count += 1
        A[j+g] = v
    return count insertionSort 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
            count += 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
            count += 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 count += 1 count 1 A[j+g] = v A[j+g] A j+g j g v return count count A A n n g g count count def shellSort(A,n):
    count = 0
    m = 0
    G = []
    while (3**(m+1)-1)//2 <= n:
        m += 1
        G.append((3**m-1)//2)
    for i in range(m):
        count = insertionSort(A,n,G[-1-i],count)
    return m,G,count shellSort count = 0 count 0 m = 0 m 0 G = [] G [] while (3**(m+1)-1)//2 <= n:
        m += 1
        G.append((3**m-1)//2)
     (3**(m+1)-1)//2 <= n (3**(m+1)-1)//2 3**(m+1)-1 3**(m+1) 3 m+1 m 1 1 2 n m += 1 m 1 G.append((3**m-1)//2) G.append G append (3**m-1)//2 3**m-1 3**m 3 m 1 2 for i in range(m):
        count = insertionSort(A,n,G[-1-i],count)
     i range(m) range m count = insertionSort(A,n,G[-1-i],count) count insertionSort(A,n,G[-1-i],count) insertionSort A n G[-1-i] G -1-i -1 i count return m,G,count return m,G,count m G count A A n n import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline N = int(input()) N int(input()) int input() input int(input()) for _ in range(N) for _ in range(N) _ range(N) range N for _ in range(N) int(input()) int input() input A = [int(input()) for _ in range(N)] A [int(input()) for _ in range(N)] m,G,count = shellSort(A,N) m shellSort(A,N) shellSort A N G count print(m) print m print(*G[::-1]) print *G[::-1] G[::-1] G ::-1 -1 print(count) print count print('\n'.join(map(str,A))) print '\n'.join(map(str,A)) '\n'.join '\n' join map(str,A) map str A count = shellSort(A,N) shellSort(A,N) count input = sys.stdin.readline sys.stdin.readline input N = int(input()) int(input()) N def shellSort(A,n):
    count = 0
    m = 0
    G = []
    while (3**(m+1)-1)//2 <= n:
        m += 1
        G.append((3**m-1)//2)
    for i in range(m):
        count = insertionSort(A,n,G[-1-i],count)
    return m,G,count def shellSort(A,n):
    count = 0
    m = 0
    G = []
    while (3**(m+1)-1)//2 <= n:
        m += 1
        G.append((3**m-1)//2)
    for i in range(m):
        count = insertionSort(A,n,G[-1-i],count)
    return m,G,count shellSort G,count = shellSort(A,N) shellSort(A,N) G def insertionSort(A,n,g,count):
    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
            count += 1
        A[j+g] = v
    return count def insertionSort(A,n,g,count):
    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
            count += 1
        A[j+g] = v
    return count insertionSort m,G,count = shellSort(A,N) shellSort(A,N) m A = [int(input()) for _ in range(N)] [int(input()) for _ in range(N)] A
def insertionSort(A,n,g,count):
    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
            count += 1
        A[j+g] = v
    return count

def shellSort(A,n):
    count = 0
    m = 0
    G = []
    while (3**(m+1)-1)//2 <= n:
        m += 1
        G.append((3**m-1)//2)
    for i in range(m):
        count = insertionSort(A,n,G[-1-i],count)
    return m,G,count

import sys
input = sys.stdin.readline

N = int(input())
A = [int(input()) for _ in range(N)]

m,G,count = shellSort(A,N)

print(m)
print(*G[::-1])
print(count)
print('\n'.join(map(str,A)))
