# -*- coding: utf-8 -*-

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 -= g
            cnt += 1
        A[j+g] = v


def shellSort(A, n):
    
    def func(m):
        if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
    G = []
    i = 0
    
    while True:
        gi = func(i)
        if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
    G = G[::-1]
    for g in G:
        insertionSort(A, n , g)
    
    return A, G


if __name__ == '__main__':

    n = int(input())
    A = [int(input()) for i in range(n)]

    cnt = 0
    A, G = shellSort(A, n)
    
    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for i in range(n):
        print(A[i])

 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 -= 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 -= 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 A A n n g g def shellSort(A, n):
    
    def func(m):
        if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
    G = []
    i = 0
    
    while True:
        gi = func(i)
        if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
    G = G[::-1]
    for g in G:
        insertionSort(A, n , g)
    
    return A, G shellSort def func(m):
        if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
     func if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
     m == 0 m 0 return 1 1 return func(m-1)*3 + 1 func(m-1)*3 + 1 func(m-1)*3 func(m-1) func m-1 m 1 3 1 m m G = [] G [] i = 0 i 0 while True:
        gi = func(i)
        if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
     True gi = func(i) gi func(i) func i if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
     gi <= n gi n G.append(gi) G.append G append gi i += 1 i 1 break G = G[::-1] G G[::-1] G ::-1 -1 for g in G:
        insertionSort(A, n , g)
    
     g G insertionSort(A, n , g) insertionSort A n g return A, G return A, G A G A A n n if __name__ == '__main__':

    n = int(input())
    A = [int(input()) for i in range(n)]

    cnt = 0
    A, G = shellSort(A, n)
    
    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for i in range(n):
        print(A[i]) __name__ == '__main__' __name__ '__main__' n = int(input()) n int(input()) int input() 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 A = [int(input()) for i in range(n)] A [int(input()) for i in range(n)] cnt = 0 cnt 0 A, G = shellSort(A, n) A shellSort(A, n) shellSort A n G print(len(G)) print len(G) len G print(" ".join(map(str, G))) print " ".join(map(str, G)) " ".join " " join map(str, G) map str 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 cnt = 0 0 cnt A, G = shellSort(A, n) shellSort(A, n) A n = int(input()) int(input()) n A = [int(input()) for i in range(n)] [int(input()) for i in range(n)] A def shellSort(A, n):
    
    def func(m):
        if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
    G = []
    i = 0
    
    while True:
        gi = func(i)
        if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
    G = G[::-1]
    for g in G:
        insertionSort(A, n , g)
    
    return A, G def shellSort(A, n):
    
    def func(m):
        if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
    G = []
    i = 0
    
    while True:
        gi = func(i)
        if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
    G = G[::-1]
    for g in G:
        insertionSort(A, n , g)
    
    return A, G shellSort G = shellSort(A, n) shellSort(A, n) G 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 -= 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 -= g
            cnt += 1
        A[j+g] = v insertionSort
# -*- coding: utf-8 -*-

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 -= g
            cnt += 1
        A[j+g] = v


def shellSort(A, n):
    
    def func(m):
        if m == 0:
            return 1
        else:
            return func(m-1)*3 + 1
    
    G = []
    i = 0
    
    while True:
        gi = func(i)
        if gi <= n:
            G.append(gi)
            i += 1
        else:
            break
    
    G = G[::-1]
    for g in G:
        insertionSort(A, n , g)
    
    return A, G


if __name__ == '__main__':

    n = int(input())
    A = [int(input()) for i in range(n)]

    cnt = 0
    A, G = shellSort(A, n)
    
    print(len(G))
    print(" ".join(map(str, G)))
    print(cnt)
    for i in range(n):
        print(A[i])


