def read_n_lows_input(n):
    Alist=[int(input()) for i in range(n)]
    return Alist

def print_list(A):
    print(*A, sep=" ")

def print_list_multi_low(A):
    for i in A:
        print(i)
    
def insertion_sort(A, n, g, cnt):
    for i in range(g-1, 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 A, cnt

def shell_sort(A, n):
    cnt = 0
    G0 = [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1]
    G = [i for i in G0 if i <= n]
    m = len(G)
    print(m)
    print_list(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    print(cnt)
    print_list_multi_low(A)

n=int(input())
A = read_n_lows_input(n)

shell_sort(A, n)
 def read_n_lows_input(n):
    Alist=[int(input()) for i in range(n)]
    return Alist read_n_lows_input int(input()) for i in range(n) for i in range(n) i range(n) range n for i in range(n) int(input()) int input() input Alist=[int(input()) for i in range(n)] Alist [int(input()) for i in range(n)] return Alist Alist n n def print_list(A):
    print(*A, sep=" ") print_list print(*A, sep=" ") print *A A sep=" " sep " " A A def print_list_multi_low(A):
    for i in A:
        print(i)
     print_list_multi_low for i in A:
        print(i)
     i A print(i) print i A A def insertion_sort(A, n, g, cnt):
    for i in range(g-1, 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 A, cnt insertion_sort for i in range(g-1, 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-1, n) range g-1 g 1 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 A, cnt return A, cnt A cnt A A n n g g cnt cnt def shell_sort(A, n):
    cnt = 0
    G0 = [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1]
    G = [i for i in G0 if i <= n]
    m = len(G)
    print(m)
    print_list(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    print(cnt)
    print_list_multi_low(A) shell_sort cnt = 0 cnt 0 G0 = [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1] G0 [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1] 797161 265720 88573 29524 9841 3280 1093 364 121 40 13 4 1 i for i in G0 if i <= n for i in G0 if i <= n i G0 i <= n i n if i <= n i G = [i for i in G0 if i <= n] G [i for i in G0 if i <= n] m = len(G) m len(G) len G print(m) print m print_list(G) print_list G for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
     i range(m) range m A, cnt = insertion_sort(A, n, G[i], cnt) A insertion_sort(A, n, G[i], cnt) insertion_sort A n G[i] G i cnt cnt print(cnt) print cnt print_list_multi_low(A) print_list_multi_low A A A n n n=int(input()) n int(input()) int input() input A = read_n_lows_input(n) A read_n_lows_input(n) read_n_lows_input n shell_sort(A, n) shell_sort A n n=int(input()) int(input()) n def print_list_multi_low(A):
    for i in A:
        print(i)
     def print_list_multi_low(A):
    for i in A:
        print(i)
     print_list_multi_low def shell_sort(A, n):
    cnt = 0
    G0 = [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1]
    G = [i for i in G0 if i <= n]
    m = len(G)
    print(m)
    print_list(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    print(cnt)
    print_list_multi_low(A) def shell_sort(A, n):
    cnt = 0
    G0 = [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1]
    G = [i for i in G0 if i <= n]
    m = len(G)
    print(m)
    print_list(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    print(cnt)
    print_list_multi_low(A) shell_sort def insertion_sort(A, n, g, cnt):
    for i in range(g-1, 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 A, cnt def insertion_sort(A, n, g, cnt):
    for i in range(g-1, 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 A, cnt insertion_sort def print_list(A):
    print(*A, sep=" ") def print_list(A):
    print(*A, sep=" ") print_list A = read_n_lows_input(n) read_n_lows_input(n) A def read_n_lows_input(n):
    Alist=[int(input()) for i in range(n)]
    return Alist def read_n_lows_input(n):
    Alist=[int(input()) for i in range(n)]
    return Alist read_n_lows_input
def read_n_lows_input(n):
    Alist=[int(input()) for i in range(n)]
    return Alist

def print_list(A):
    print(*A, sep=" ")

def print_list_multi_low(A):
    for i in A:
        print(i)
    
def insertion_sort(A, n, g, cnt):
    for i in range(g-1, 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 A, cnt

def shell_sort(A, n):
    cnt = 0
    G0 = [797161, 265720, 88573, 29524, 9841, 3280, 1093, 364, 121, 40, 13, 4, 1]
    G = [i for i in G0 if i <= n]
    m = len(G)
    print(m)
    print_list(G)
    for i in range(m):
        A, cnt = insertion_sort(A, n, G[i], cnt)
    print(cnt)
    print_list_multi_low(A)

n=int(input())
A = read_n_lows_input(n)

shell_sort(A, n)

