def insertion_sort(A):
    for i in range(1, len(A)):
        print(A)
        v = A[i]
        j = i - 1
        while (j >= 0) and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
    return A


def bubble_sort(A):
    cnt = 0
    flag = True
    while flag:
        flag = False
        for i in sorted(range(1, len(A)), reverse=True):
            if A[i] < A[i - 1]:
                cnt += 1
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = True
    return A, cnt


def selection_sort(A):
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
    return A


def insertion_sort_for_shell(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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):
    cnt = 0
    G = []
    g = 1
    while True:
        G.append(g)
        g = g *3 + 1
        if g > len(A):
            break
    G = sorted(G, reverse=True)
    for g in G:
        A, c = insertion_sort_for_shell(A, g)
        cnt += c
    return A, G, cnt


def print_shell_sort_result(A, G, cnt):
    print(len(G))
    print(' '.join(map(str, G)))
    print(cnt)
    [print(a) for a in A]

if __name__ == '__main__':
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())
    print_shell_sort_result(*shell_sort(A)) def insertion_sort(A):
    for i in range(1, len(A)):
        print(A)
        v = A[i]
        j = i - 1
        while (j >= 0) and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
    return A insertion_sort for i in range(1, len(A)):
        print(A)
        v = A[i]
        j = i - 1
        while (j >= 0) and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
     i range(1, len(A)) range 1 len(A) len A print(A) print A v = A[i] v A[i] A i j = i - 1 j i - 1 i 1 while (j >= 0) and A[j] > v:
            A[j+1] = A[j]
            j -= 1
         (j >= 0) and A[j] > v j >= 0 j 0 A[j] > v A[j] A j v A[j+1] = A[j] A[j+1] A j+1 j 1 A[j] A j j -= 1 j 1 A[j+1] = v A[j+1] A j+1 j 1 v return A A A A def bubble_sort(A):
    cnt = 0
    flag = True
    while flag:
        flag = False
        for i in sorted(range(1, len(A)), reverse=True):
            if A[i] < A[i - 1]:
                cnt += 1
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = True
    return A, cnt bubble_sort cnt = 0 cnt 0 flag = True flag True while flag:
        flag = False
        for i in sorted(range(1, len(A)), reverse=True):
            if A[i] < A[i - 1]:
                cnt += 1
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = True
     flag flag = False flag False for i in sorted(range(1, len(A)), reverse=True):
            if A[i] < A[i - 1]:
                cnt += 1
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = True
     i sorted(range(1, len(A)), reverse=True) sorted range(1, len(A)) range 1 len(A) len A reverse=True reverse True if A[i] < A[i - 1]:
                cnt += 1
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = True
     A[i] < A[i - 1] A[i] A i A[i - 1] A i - 1 i 1 cnt += 1 cnt 1 tmp = A[i] tmp A[i] A i A[i] = A[i - 1] A[i] A i A[i - 1] A i - 1 i 1 A[i - 1] = tmp A[i - 1] A i - 1 i 1 tmp flag = True flag True return A, cnt return A, cnt A cnt A A def selection_sort(A):
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
    return A selection_sort for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
     i range(len(A)) range len(A) len A minj = i minj i for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
         j range(i, len(A)) range i len(A) len A if A[j] < A[minj]:
                minj = j
         A[j] < A[minj] A[j] A j A[minj] A minj minj = j minj j tmp = A[i] tmp A[i] A i A[i] = A[minj] A[i] A i A[minj] A minj A[minj] = tmp A[minj] A minj tmp return A A A A def insertion_sort_for_shell(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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_shell cnt = 0 cnt 0 for i in range(g, len(A)):
        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, len(A)) range g len(A) len A 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 g g def shell_sort(A):
    cnt = 0
    G = []
    g = 1
    while True:
        G.append(g)
        g = g *3 + 1
        if g > len(A):
            break
    G = sorted(G, reverse=True)
    for g in G:
        A, c = insertion_sort_for_shell(A, g)
        cnt += c
    return A, G, cnt shell_sort cnt = 0 cnt 0 G = [] G [] g = 1 g 1 while True:
        G.append(g)
        g = g *3 + 1
        if g > len(A):
            break
     True G.append(g) G.append G append g g = g *3 + 1 g g *3 + 1 g *3 g 3 1 if g > len(A):
            break
     g > len(A) g len(A) len A break G = sorted(G, reverse=True) G sorted(G, reverse=True) sorted G reverse=True reverse True for g in G:
        A, c = insertion_sort_for_shell(A, g)
        cnt += c
     g G A, c = insertion_sort_for_shell(A, g) A insertion_sort_for_shell(A, g) insertion_sort_for_shell A g c cnt += c cnt c return A, G, cnt return A, G, cnt A G cnt A A def print_shell_sort_result(A, G, cnt):
    print(len(G))
    print(' '.join(map(str, G)))
    print(cnt)
    [print(a) for a in A] print_shell_sort_result 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 print(a) for a in A for a in A a A for a in A print(a) print a [print(a) for a in A] A A G G cnt cnt if __name__ == '__main__':
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())
    print_shell_sort_result(*shell_sort(A)) __name__ == '__main__' __name__ '__main__' 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 print_shell_sort_result(*shell_sort(A)) print_shell_sort_result *shell_sort(A) shell_sort(A) shell_sort A A = [0] * N [0] * N A def insertion_sort_for_shell(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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_for_shell(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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_shell def insertion_sort(A):
    for i in range(1, len(A)):
        print(A)
        v = A[i]
        j = i - 1
        while (j >= 0) and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
    return A def insertion_sort(A):
    for i in range(1, len(A)):
        print(A)
        v = A[i]
        j = i - 1
        while (j >= 0) and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
    return A insertion_sort N = int(input()) int(input()) N def print_shell_sort_result(A, G, cnt):
    print(len(G))
    print(' '.join(map(str, G)))
    print(cnt)
    [print(a) for a in A] def print_shell_sort_result(A, G, cnt):
    print(len(G))
    print(' '.join(map(str, G)))
    print(cnt)
    [print(a) for a in A] print_shell_sort_result def bubble_sort(A):
    cnt = 0
    flag = True
    while flag:
        flag = False
        for i in sorted(range(1, len(A)), reverse=True):
            if A[i] < A[i - 1]:
                cnt += 1
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = True
    return A, cnt def bubble_sort(A):
    cnt = 0
    flag = True
    while flag:
        flag = False
        for i in sorted(range(1, len(A)), reverse=True):
            if A[i] < A[i - 1]:
                cnt += 1
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = True
    return A, cnt bubble_sort def selection_sort(A):
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
    return A def selection_sort(A):
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
    return A selection_sort def shell_sort(A):
    cnt = 0
    G = []
    g = 1
    while True:
        G.append(g)
        g = g *3 + 1
        if g > len(A):
            break
    G = sorted(G, reverse=True)
    for g in G:
        A, c = insertion_sort_for_shell(A, g)
        cnt += c
    return A, G, cnt def shell_sort(A):
    cnt = 0
    G = []
    g = 1
    while True:
        G.append(g)
        g = g *3 + 1
        if g > len(A):
            break
    G = sorted(G, reverse=True)
    for g in G:
        A, c = insertion_sort_for_shell(A, g)
        cnt += c
    return A, G, cnt shell_sort
def insertion_sort(A):
    for i in range(1, len(A)):
        print(A)
        v = A[i]
        j = i - 1
        while (j >= 0) and A[j] > v:
            A[j+1] = A[j]
            j -= 1
        A[j+1] = v
    return A


def bubble_sort(A):
    cnt = 0
    flag = True
    while flag:
        flag = False
        for i in sorted(range(1, len(A)), reverse=True):
            if A[i] < A[i - 1]:
                cnt += 1
                tmp = A[i]
                A[i] = A[i - 1]
                A[i - 1] = tmp
                flag = True
    return A, cnt


def selection_sort(A):
    for i in range(len(A)):
        minj = i
        for j in range(i, len(A)):
            if A[j] < A[minj]:
                minj = j
        tmp = A[i]
        A[i] = A[minj]
        A[minj] = tmp
    return A


def insertion_sort_for_shell(A, g):
    cnt = 0
    for i in range(g, len(A)):
        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):
    cnt = 0
    G = []
    g = 1
    while True:
        G.append(g)
        g = g *3 + 1
        if g > len(A):
            break
    G = sorted(G, reverse=True)
    for g in G:
        A, c = insertion_sort_for_shell(A, g)
        cnt += c
    return A, G, cnt


def print_shell_sort_result(A, G, cnt):
    print(len(G))
    print(' '.join(map(str, G)))
    print(cnt)
    [print(a) for a in A]

if __name__ == '__main__':
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())
    print_shell_sort_result(*shell_sort(A))