cnt = 0


def insertion_sort(seq, n, g):
    global cnt
    for i in range(g, n):
        v = seq[i]
        j = i - g
        while j >= 0 and seq[j] > v:
            seq[j + g] = seq[j]
            j = j - g
            cnt = cnt + 1
        seq[j + g] = v


def shell_sort(seq, n):
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    print(len(G))
    print(' '.join(map(str, reversed(G))))

    for g in reversed(G):
        insertion_sort(seq, n, g)
    return seq

n = int(input())
a = [int(input()) for _ in range(n)]
ans = shell_sort(a, n)
print(cnt)
print('\n'.join(map(str, ans))) cnt = 0 cnt 0 def insertion_sort(seq, n, g):
    global cnt
    for i in range(g, n):
        v = seq[i]
        j = i - g
        while j >= 0 and seq[j] > v:
            seq[j + g] = seq[j]
            j = j - g
            cnt = cnt + 1
        seq[j + g] = v insertion_sort global cnt for i in range(g, n):
        v = seq[i]
        j = i - g
        while j >= 0 and seq[j] > v:
            seq[j + g] = seq[j]
            j = j - g
            cnt = cnt + 1
        seq[j + g] = v i range(g, n) range g n v = seq[i] v seq[i] seq i j = i - g j i - g i g while j >= 0 and seq[j] > v:
            seq[j + g] = seq[j]
            j = j - g
            cnt = cnt + 1
         j >= 0 and seq[j] > v j >= 0 j 0 seq[j] > v seq[j] seq j v seq[j + g] = seq[j] seq[j + g] seq j + g j g seq[j] seq j j = j - g j j - g j g cnt = cnt + 1 cnt cnt + 1 cnt 1 seq[j + g] = v seq[j + g] seq j + g j g v seq seq n n g g def shell_sort(seq, n):
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    print(len(G))
    print(' '.join(map(str, reversed(G))))

    for g in reversed(G):
        insertion_sort(seq, n, g)
    return seq shell_sort g = 1 g 1 G = [] G [] while g <= n:
        G.append(g)
        g = 3 * g + 1
     g <= n g n G.append(g) G.append G append g g = 3 * g + 1 g 3 * g + 1 3 * g 3 g 1 print(len(G)) print len(G) len G print(' '.join(map(str, reversed(G)))) print ' '.join(map(str, reversed(G))) ' '.join ' ' join map(str, reversed(G)) map str reversed(G) reversed G for g in reversed(G):
        insertion_sort(seq, n, g)
     g reversed(G) reversed G insertion_sort(seq, n, g) insertion_sort seq n g return seq seq seq seq n n 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)] ans = shell_sort(a, n) ans shell_sort(a, n) shell_sort a n print(cnt) print cnt print('\n'.join(map(str, ans))) print '\n'.join(map(str, ans)) '\n'.join '\n' join map(str, ans) map str ans a = [int(input()) for _ in range(n)] [int(input()) for _ in range(n)] a def shell_sort(seq, n):
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    print(len(G))
    print(' '.join(map(str, reversed(G))))

    for g in reversed(G):
        insertion_sort(seq, n, g)
    return seq def shell_sort(seq, n):
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    print(len(G))
    print(' '.join(map(str, reversed(G))))

    for g in reversed(G):
        insertion_sort(seq, n, g)
    return seq shell_sort def insertion_sort(seq, n, g):
    global cnt
    for i in range(g, n):
        v = seq[i]
        j = i - g
        while j >= 0 and seq[j] > v:
            seq[j + g] = seq[j]
            j = j - g
            cnt = cnt + 1
        seq[j + g] = v def insertion_sort(seq, n, g):
    global cnt
    for i in range(g, n):
        v = seq[i]
        j = i - g
        while j >= 0 and seq[j] > v:
            seq[j + g] = seq[j]
            j = j - g
            cnt = cnt + 1
        seq[j + g] = v insertion_sort cnt = 0 0 cnt ans = shell_sort(a, n) shell_sort(a, n) ans n = int(input()) int(input()) n
cnt = 0


def insertion_sort(seq, n, g):
    global cnt
    for i in range(g, n):
        v = seq[i]
        j = i - g
        while j >= 0 and seq[j] > v:
            seq[j + g] = seq[j]
            j = j - g
            cnt = cnt + 1
        seq[j + g] = v


def shell_sort(seq, n):
    g = 1
    G = []
    while g <= n:
        G.append(g)
        g = 3 * g + 1
    print(len(G))
    print(' '.join(map(str, reversed(G))))

    for g in reversed(G):
        insertion_sort(seq, n, g)
    return seq

n = int(input())
a = [int(input()) for _ in range(n)]
ans = shell_sort(a, n)
print(cnt)
print('\n'.join(map(str, ans)))