import math


def insertion_sort(A, N, g, 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
    return cnt


def shell_sort(A, N, cnt):
    G = []
    g = 1
    m = 0
    while g <= N:
        G.append(g)
        m += 1
        g = 3 * g + 1
    G.reverse()

    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for g in G:
        cnt = insertion_sort(A, N, g, cnt)

    return cnt


if __name__ == "__main__":
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))

    cnt = 0
    cnt = shell_sort(A, N, cnt)

    print(cnt)
    for a in A:
        print(a)
 import math math def insertion_sort(A, N, g, 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
    return cnt insertion_sort 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 return cnt cnt A A N N g g cnt cnt def shell_sort(A, N, cnt):
    G = []
    g = 1
    m = 0
    while g <= N:
        G.append(g)
        m += 1
        g = 3 * g + 1
    G.reverse()

    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for g in G:
        cnt = insertion_sort(A, N, g, cnt)

    return cnt shell_sort G = [] G [] g = 1 g 1 m = 0 m 0 while g <= N:
        G.append(g)
        m += 1
        g = 3 * g + 1
     g <= N g N G.append(g) G.append G append g m += 1 m 1 g = 3 * g + 1 g 3 * g + 1 3 * g 3 g 1 G.reverse() G.reverse G reverse m = len(G) m len(G) len G print(m) print m print(' '.join(map(str, G))) print ' '.join(map(str, G)) ' '.join ' ' join map(str, G) map str G for g in G:
        cnt = insertion_sort(A, N, g, cnt)

     g G cnt = insertion_sort(A, N, g, cnt) cnt insertion_sort(A, N, g, cnt) insertion_sort A N g cnt return cnt cnt A A N N cnt cnt if __name__ == "__main__":
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))

    cnt = 0
    cnt = shell_sort(A, N, cnt)

    print(cnt)
    for a in A:
        print(a) __name__ == "__main__" __name__ "__main__" N = int(input()) N int(input()) int input() input A = [] A [] for i in range(N):
        A.append(int(input()))

     i range(N) range N A.append(int(input())) A.append A append int(input()) int input() input cnt = 0 cnt 0 cnt = shell_sort(A, N, cnt) cnt shell_sort(A, N, cnt) shell_sort A N cnt print(cnt) print cnt for a in A:
        print(a) a A print(a) print a def shell_sort(A, N, cnt):
    G = []
    g = 1
    m = 0
    while g <= N:
        G.append(g)
        m += 1
        g = 3 * g + 1
    G.reverse()

    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for g in G:
        cnt = insertion_sort(A, N, g, cnt)

    return cnt def shell_sort(A, N, cnt):
    G = []
    g = 1
    m = 0
    while g <= N:
        G.append(g)
        m += 1
        g = 3 * g + 1
    G.reverse()

    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for g in G:
        cnt = insertion_sort(A, N, g, cnt)

    return cnt shell_sort cnt = 0 0 cnt A = [] [] A N = int(input()) int(input()) N def insertion_sort(A, N, g, 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
    return cnt def insertion_sort(A, N, g, 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
    return cnt insertion_sort cnt = shell_sort(A, N, cnt) shell_sort(A, N, cnt) cnt
import math


def insertion_sort(A, N, g, 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
    return cnt


def shell_sort(A, N, cnt):
    G = []
    g = 1
    m = 0
    while g <= N:
        G.append(g)
        m += 1
        g = 3 * g + 1
    G.reverse()

    m = len(G)
    print(m)
    print(' '.join(map(str, G)))
    for g in G:
        cnt = insertion_sort(A, N, g, cnt)

    return cnt


if __name__ == "__main__":
    N = int(input())
    A = []
    for i in range(N):
        A.append(int(input()))

    cnt = 0
    cnt = shell_sort(A, N, cnt)

    print(cnt)
    for a in A:
        print(a)

